Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754716AbXFNRWd (ORCPT ); Thu, 14 Jun 2007 13:22:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751254AbXFNRW0 (ORCPT ); Thu, 14 Jun 2007 13:22:26 -0400 Received: from mail.screens.ru ([213.234.233.54]:55333 "EHLO mail.screens.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbXFNRWZ (ORCPT ); Thu, 14 Jun 2007 13:22:25 -0400 Date: Thu, 14 Jun 2007 21:22:43 +0400 From: Oleg Nesterov To: Andrew Morton Cc: Benjamin Herrenschmidt , Paul Clements , Pavel Machek , Roland McGrath , linux-kernel@vger.kernel.org Subject: [PATCH] nbd.c:sock_xmit: cleanup signal related code Message-ID: <20070614172243.GA2446@tv-sign.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.11 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2162 Lines: 62 sock_xmit() re-implements sigprocmask() and dequeue_signal_lock(). Note: I can't understand this dequeue_signal(), it can dequeue SIGKILL for the user-space task doing nbd_ioctl() ? Signed-off-by: Oleg Nesterov --- sig/drivers/block/nbd.c~1_nbd 2007-05-21 13:57:50.000000000 +0400 +++ sig/drivers/block/nbd.c 2007-06-14 19:39:55.000000000 +0400 @@ -122,17 +122,12 @@ static int sock_xmit(struct socket *sock int result; struct msghdr msg; struct kvec iov; - unsigned long flags; - sigset_t oldset; + sigset_t blocked, oldset; /* Allow interception of SIGKILL only * Don't allow other signals to interrupt the transmission */ - spin_lock_irqsave(¤t->sighand->siglock, flags); - oldset = current->blocked; - sigfillset(¤t->blocked); - sigdelsetmask(¤t->blocked, sigmask(SIGKILL)); - recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); + siginitsetinv(&blocked, sigmask(SIGKILL)); + sigprocmask(SIG_SETMASK, &blocked, &oldset); do { sock->sk->sk_allocation = GFP_NOIO; @@ -151,11 +146,9 @@ static int sock_xmit(struct socket *sock if (signal_pending(current)) { siginfo_t info; - spin_lock_irqsave(¤t->sighand->siglock, flags); printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n", - current->pid, current->comm, - dequeue_signal(current, ¤t->blocked, &info)); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); + current->pid, current->comm, + dequeue_signal_lock(current, ¤t->blocked, &info)); result = -EINTR; break; } @@ -169,10 +162,7 @@ static int sock_xmit(struct socket *sock buf += result; } while (size > 0); - spin_lock_irqsave(¤t->sighand->siglock, flags); - current->blocked = oldset; - recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); + sigprocmask(SIG_SETMASK, &oldset, NULL); return result; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/