public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Matt Fleming <matt@console-pimps.org>
Cc: linux-kernel@vger.kernel.org,
	Petr Vandrovec <petr@vandrovec.name>,
	Al Viro <viro@zeniv.linux.org.uk>, Arnd Bergmann <arnd@arndb.de>,
	linux-fsdevel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 40/41] ncpfs: Use set_current_blocked()
Date: Wed, 17 Aug 2011 16:41:39 +0200	[thread overview]
Message-ID: <20110817144139.GA17271@redhat.com> (raw)
In-Reply-To: <1313589483.2311.24.camel@mfleming-mobl1.ger.corp.intel.com>

On 08/17, Matt Fleming wrote:
>
> On Wed, 2011-08-17 at 14:04 +0200, Oleg Nesterov wrote:
> > On 08/16, Matt Fleming wrote:
> > >
> > > > the sighand->action[] checks are racy anyway in the mt case, siglock
> > > > can't help.
> > >
> > > Hmm.. really? I thought that ->siglock serialised modifications to
> > > sighand->action[] even in the mt case, no?
> >
> > Sure. But another thread can change sighand->action[] right after we
> > drop ->siglock. So how can this lock help? We simply read the word,
> > this is atomic and doesn't need the locking.
>
> Oh right, in the scenario in ncp_do_request(), sure I understand that. I
> thought you were saying that in the general case ->siglock doesn't
> protect sighand->action[]! That's why I was confused ;-)
>
> OK, how about this patch (instead of 40/41) which gets rid of all the
> nasties? I've Cc'd linux-fsdevel so people can hopefully OK this from a
> file system perspective.

Well, of course I am in no position to ack this change ;)

But obviously I like the idea to kill the obviously wrong code.
In particular, the PF_EXITING/SIGKILL logic looks as "must die
in any case" to me.

If maintainers object, you can remove ->siglock and convert the code
to use set_current_blocked(). IOW, simplify your original patch.

Oleg.

> From bb1650295054bdfa96f8f4ff61507d314be8296a Mon Sep 17 00:00:00 2001
> From: Matt Fleming <matt.fleming@intel.com>
> Date: Wed, 17 Aug 2011 13:59:12 +0100
> Subject: [PATCH] ncpfs: Don't attempt to mask signals during
>  do_ncp_rpc_call()
> 
> Delete the code in ncp_do_request() that attempts to mask signals
> across the call to do_ncp_rpc_call(). This code was racy because it
> dropped ->siglock across do_ncp_rpc_call() so it was possible for
> another thread to modify the signal handlers, which made the code
> pointless.
> 
> Instead of fixing the code to hold the lock across the call let's just
> delete it because, as the FIXME comment (which has been around since
> the beginning of git history) says, trying to block signals doesn't
> seem right at all.
> 
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
>  fs/ncpfs/sock.c |   32 +-------------------------------
>  1 files changed, 1 insertions(+), 31 deletions(-)
> 
> diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
> index 3a15872..6618402 100644
> --- a/fs/ncpfs/sock.c
> +++ b/fs/ncpfs/sock.c
> @@ -748,38 +748,8 @@ static int ncp_do_request(struct ncp_server *server, int size,
>  	if (!ncp_conn_valid(server)) {
>  		return -EIO;
>  	}
> -	{
> -		sigset_t old_set;
> -		unsigned long mask, flags;
> -
> -		spin_lock_irqsave(&current->sighand->siglock, flags);
> -		old_set = current->blocked;
> -		if (current->flags & PF_EXITING)
> -			mask = 0;
> -		else
> -			mask = sigmask(SIGKILL);
> -		if (server->m.flags & NCP_MOUNT_INTR) {
> -			/* FIXME: This doesn't seem right at all.  So, like,
> -			   we can't handle SIGINT and get whatever to stop?
> -			   What if we've blocked it ourselves?  What about
> -			   alarms?  Why, in fact, are we mucking with the
> -			   sigmask at all? -- r~ */
> -			if (current->sighand->action[SIGINT - 1].sa.sa_handler == SIG_DFL)
> -				mask |= sigmask(SIGINT);
> -			if (current->sighand->action[SIGQUIT - 1].sa.sa_handler == SIG_DFL)
> -				mask |= sigmask(SIGQUIT);
> -		}
> -		siginitsetinv(&current->blocked, mask);
> -		recalc_sigpending();
> -		spin_unlock_irqrestore(&current->sighand->siglock, flags);
> -		
> -		result = do_ncp_rpc_call(server, size, reply, max_reply_size);
>  
> -		spin_lock_irqsave(&current->sighand->siglock, flags);
> -		current->blocked = old_set;
> -		recalc_sigpending();
> -		spin_unlock_irqrestore(&current->sighand->siglock, flags);
> -	}
> +	result = do_ncp_rpc_call(server, size, reply, max_reply_size);
>  
>  	DDPRINTK("do_ncp_rpc_call returned %d\n", result);
>  
> -- 
> 1.7.4.4
> 
> 


  reply	other threads:[~2011-08-17 14:44 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11 13:56 [PATCH 00/41] signal: Use set_current_blocked() Matt Fleming
2011-08-11 13:56 ` [PATCH 01/41] alpha: " Matt Fleming
2011-08-11 13:56 ` [PATCH 02/41] arm: " Matt Fleming
2011-08-11 17:04   ` Will Deacon
2011-08-11 13:56 ` [PATCH 03/41] avr32: Don't mask signals in the error path Matt Fleming
2011-08-11 13:56 ` [PATCH 04/41] avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn Matt Fleming
2011-08-11 13:56 ` [PATCH 05/41] blackfin: Use set_current_blocked() Matt Fleming
2011-08-11 13:56 ` [PATCH 06/41] cris: " Matt Fleming
2011-08-11 13:56 ` [PATCH 07/41] frv: " Matt Fleming
2011-08-11 13:56 ` [PATCH 08/41] h8300: " Matt Fleming
2011-08-11 13:56 ` [PATCH 09/41] ia64: " Matt Fleming
2011-08-11 13:56 ` [PATCH 10/41] m32r: " Matt Fleming
2011-08-11 13:56 ` [PATCH 11/41] m68k: " Matt Fleming
2011-08-11 13:56 ` [PATCH 12/41] microblaze: Don't reimplement force_sigsegv() Matt Fleming
2011-08-16 17:20   ` Oleg Nesterov
2011-08-16 17:20     ` Oleg Nesterov
2011-08-17 13:01       ` Michal Simek
2011-08-17 13:14         ` Oleg Nesterov
2011-08-17 13:25           ` Matt Fleming
2011-08-17 13:17         ` Matt Fleming
2011-08-17 13:22           ` Michal Simek
2011-08-11 13:56 ` [PATCH 13/41] microblaze: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-11 13:56 ` [PATCH 14/41] microblaze: Fix signal masking Matt Fleming
2011-08-11 13:56 ` [PATCH 15/41] microblaze: Use set_current_blocked() Matt Fleming
2011-08-11 13:56 ` [PATCH 16/41] MIPS: " Matt Fleming
2011-08-11 13:56 ` [PATCH 17/41] mn10300: " Matt Fleming
2011-08-11 13:56 ` [PATCH 18/41] OpenRISC: Don't reimplement force_sigsegv() Matt Fleming
2011-08-16 16:49   ` Oleg Nesterov
2011-08-16 19:33     ` Matt Fleming
2011-08-18 17:47       ` Oleg Nesterov
2011-08-11 13:56 ` [PATCH 19/41] OpenRISC: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-16 16:53   ` Oleg Nesterov
2011-08-11 13:56 ` [PATCH 20/41] OpenRISC: Don't mask signals if we fail to setup signal stack Matt Fleming
2011-08-11 13:56 ` [PATCH 21/41] OpenRISC: Use set_current_blocked() Matt Fleming
2011-08-11 13:56 ` [PATCH 22/41] parisc: " Matt Fleming
2011-08-11 13:56 ` [PATCH 23/41] powerpc: " Matt Fleming
2011-08-11 13:56 ` [PATCH 24/41] score: Don't mask signals if we fail to setup signal stack Matt Fleming
2011-08-11 13:56 ` [PATCH 25/41] score: Use set_current_blocked() Matt Fleming
2011-08-11 13:57 ` [PATCH 26/41] sh: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-16 17:25   ` Oleg Nesterov
2011-08-11 13:57 ` [PATCH 27/41] sh: Use set_current_blocked() Matt Fleming
2011-08-11 13:57 ` [PATCH 28/41] sparc: " Matt Fleming
2011-08-11 13:57 ` [PATCH 29/41] tile: " Matt Fleming
2011-08-11 17:10   ` Chris Metcalf
2011-08-11 13:57 ` [PATCH 30/41] um: " Matt Fleming
2011-08-11 13:57 ` [PATCH 31/41] um: Don't restore current->blocked on error Matt Fleming
2011-08-16 17:38   ` Oleg Nesterov
2011-08-11 13:57 ` [PATCH 32/41] unicore32: Use set_current_blocked() Matt Fleming
2011-08-18  8:34   ` Guan Xuetao
2011-08-11 13:57 ` [PATCH 33/41] xtensa: Don't reimplement force_sigsegv() Matt Fleming
2011-08-16 17:40   ` Oleg Nesterov
2011-08-11 13:57 ` [PATCH 34/41] xtensa: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-11 13:57 ` [PATCH 35/41] xtensa: Don't mask signals if we fail to setup signal stack Matt Fleming
2011-08-11 13:57 ` [PATCH 36/41] xtensa: Use set_current_blocked() Matt Fleming
2011-08-11 13:57 ` [PATCH 37/41] autofs4: " Matt Fleming
2011-08-16 17:47   ` Oleg Nesterov
2011-08-16 20:29     ` Matt Fleming
2011-08-11 13:57 ` [PATCH 38/41] coda: " Matt Fleming
2011-08-11 13:57 ` [PATCH 39/41] dlm: Remove another superfluous call to recalc_sigpending() Matt Fleming
2011-08-11 15:39   ` David Teigland
2011-08-16 19:36   ` Oleg Nesterov
2011-08-11 13:57 ` [PATCH 40/41] ncpfs: Use set_current_blocked() Matt Fleming
2011-08-16 17:56   ` Oleg Nesterov
2011-08-16 20:56     ` Matt Fleming
2011-08-17 12:04       ` Oleg Nesterov
2011-08-17 13:58         ` Matt Fleming
2011-08-17 14:41           ` Oleg Nesterov [this message]
     [not found]             ` <CA+i2_De=mKMHj++b5=ZPdXxp7pm2KzY+PzCaG++GWSud20a_qQ@mail.gmail.com>
2011-08-18 17:05               ` Oleg Nesterov
2011-08-18 20:09                 ` Matt Fleming
2011-08-11 13:57 ` [PATCH 41/41] exit: Use __set_task_blocked() Matt Fleming
2011-08-16 18:06   ` Oleg Nesterov
2011-08-16 19:44     ` [PATCH 0/1] kthreads: allow_signal: don't play with ->blocked Oleg Nesterov
2011-08-16 19:44       ` [PATCH 1/1] " Oleg Nesterov
2011-08-16 19:51         ` Tejun Heo
2011-08-16 20:07           ` Oleg Nesterov
2011-08-16 21:50           ` Matt Fleming
2011-08-17  7:27             ` Tejun Heo
2011-08-17  9:56               ` Matt Fleming
2011-08-17 18:26               ` Oleg Nesterov
2011-08-16 21:51     ` [PATCH 41/41] exit: Use __set_task_blocked() Matt Fleming
2011-08-11 16:03 ` [PATCH 00/41] signal: Use set_current_blocked() Oleg Nesterov
2011-08-16 19:40   ` Matt Fleming
2011-08-17 17:01     ` Oleg Nesterov
2011-08-17 22:17       ` Matt Fleming
2011-08-18 11:09         ` Matt Fleming
2011-08-18 18:36           ` Oleg Nesterov
2011-08-16 19:58 ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110817144139.GA17271@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@console-pimps.org \
    --cc=petr@vandrovec.name \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox