[PATCH v2 43/43] ncpfs: Use set_current_blocked()

From: Matt Fleming
Date: Fri Aug 19 2011 - 12:49:12 EST


From: Matt Fleming <matt.fleming@xxxxxxxxx>

As described in e6fa16ab ("signal: sigprocmask() should do
retarget_shared_pending()") the modification of current->blocked is
incorrect as we need to check whether the signal we're about to block
is pending in the shared queue.

Also, there's no need to hold sighand->siglock while reading
sighand->action[] because the lock is dropped across the call to
do_ncp_rpc_call() during which time another thread could modify
->action[].

Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
Cc: Petr Vandrovec <petr@xxxxxxxxxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Signed-off-by: Matt Fleming <matt.fleming@xxxxxxxxx>
---
fs/ncpfs/sock.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 3a15872..850768a 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -749,10 +749,9 @@ static int ncp_do_request(struct ncp_server *server, int size,
return -EIO;
}
{
- sigset_t old_set;
- unsigned long mask, flags;
+ sigset_t old_set, blocked;
+ unsigned long mask;

- spin_lock_irqsave(&current->sighand->siglock, flags);
old_set = current->blocked;
if (current->flags & PF_EXITING)
mask = 0;
@@ -769,16 +768,12 @@ static int ncp_do_request(struct ncp_server *server, int size,
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);
+ siginitsetinv(&blocked, mask);
+ set_current_blocked(&blocked);

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);
+ set_current_blocked(&old_set);
}

DDPRINTK("do_ncp_rpc_call returned %d\n", result);
--
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/