From: Matt Fleming <matt@console-pimps.org> To: linux-arch@vger.kernel.org Cc: Nicolas Pitre <nicolas.pitre@linaro.org>, Dave Martin <dave.martin@linaro.org>, Matt Fleming <matt.fleming@intel.com>, Russell King <linux@arm.linux.org.uk>, Will Deacon <will.deacon@arm.com>, Oleg Nesterov <oleg@redhat.com>, linux-kernel@vger.kernel.org, Arnd Bergmann <arnd.bergmann@linaro.org>, Andrew Morton <akpm@linux-foundation.org>, linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/40] arm: Use set_current_blocked() and block_sigmask() Date: Tue, 14 Feb 2012 11:40:35 +0000 [thread overview] Message-ID: <1329219673-28711-3-git-send-email-matt@console-pimps.org> (raw) In-Reply-To: <1329219673-28711-1-git-send-email-matt@console-pimps.org> From: Matt Fleming <matt.fleming@intel.com> As described in e6fa16ab ("signal: sigprocmask() should do retarget_shared_pending()") the modification of current->blocked is incorrect as we need to check for shared signals we're about to block. Also, use the new helper function introduced in commit 5e6292c0f28f ("signal: add block_sigmask() for adding sigmask to current->blocked") which centralises the code for updating current->blocked after successfully delivering a signal and reduces the amount of duplicate code across architectures. In the past some architectures got this code wrong, so using this helper function should stop that from happening again. Cc: Oleg Nesterov <oleg@redhat.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Arnd Bergmann <arnd.bergmann@linaro.org> Cc: Dave Martin <dave.martin@linaro.org> Cc: Nicolas Pitre <nicolas.pitre@linaro.org> Cc: Will Deacon <will.deacon@arm.com> Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Matt Fleming <matt.fleming@intel.com> --- arch/arm/kernel/signal.c | 24 ++++++++---------------- 1 files changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 9e617bd..7cb532f 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -66,12 +66,13 @@ const unsigned long syscall_restart_code[2] = { */ asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask) { - mask &= _BLOCKABLE; - spin_lock_irq(¤t->sighand->siglock); + sigset_t blocked; + current->saved_sigmask = current->blocked; - siginitset(¤t->blocked, mask); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + + mask &= _BLOCKABLE; + siginitset(&blocked, mask); + set_current_blocked(&blocked); current->state = TASK_INTERRUPTIBLE; schedule(); @@ -280,10 +281,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf) err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); if (err == 0) { sigdelsetmask(&set, ~_BLOCKABLE); - spin_lock_irq(¤t->sighand->siglock); - current->blocked = set; - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + set_current_blocked(&set); } __get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); @@ -636,13 +634,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, /* * Block the signal if we were successful. */ - spin_lock_irq(&tsk->sighand->siglock); - sigorsets(&tsk->blocked, &tsk->blocked, - &ka->sa.sa_mask); - if (!(ka->sa.sa_flags & SA_NODEFER)) - sigaddset(&tsk->blocked, sig); - recalc_sigpending(); - spin_unlock_irq(&tsk->sighand->siglock); + block_sigmask(ka, sig); return 0; } -- 1.7.4.4
WARNING: multiple messages have this Message-ID (diff)
From: Matt Fleming <matt@console-pimps.org> To: linux-arch@vger.kernel.org Cc: Oleg Nesterov <oleg@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, Matt Fleming <matt.fleming@intel.com>, Russell King <linux@arm.linux.org.uk>, Arnd Bergmann <arnd.bergmann@linaro.org>, Dave Martin <dave.martin@linaro.org>, Nicolas Pitre <nicolas.pitre@linaro.org>, Will Deacon <will.deacon@arm.com>, linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/40] arm: Use set_current_blocked() and block_sigmask() Date: Tue, 14 Feb 2012 11:40:35 +0000 [thread overview] Message-ID: <1329219673-28711-3-git-send-email-matt@console-pimps.org> (raw) Message-ID: <20120214114035.ubF8P1FWYlq6xPescWU65ODBV2oJyYetGNvR2IcfP_8@z> (raw) In-Reply-To: <1329219673-28711-1-git-send-email-matt@console-pimps.org> From: Matt Fleming <matt.fleming@intel.com> As described in e6fa16ab ("signal: sigprocmask() should do retarget_shared_pending()") the modification of current->blocked is incorrect as we need to check for shared signals we're about to block. Also, use the new helper function introduced in commit 5e6292c0f28f ("signal: add block_sigmask() for adding sigmask to current->blocked") which centralises the code for updating current->blocked after successfully delivering a signal and reduces the amount of duplicate code across architectures. In the past some architectures got this code wrong, so using this helper function should stop that from happening again. Cc: Oleg Nesterov <oleg@redhat.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Arnd Bergmann <arnd.bergmann@linaro.org> Cc: Dave Martin <dave.martin@linaro.org> Cc: Nicolas Pitre <nicolas.pitre@linaro.org> Cc: Will Deacon <will.deacon@arm.com> Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Matt Fleming <matt.fleming@intel.com> --- arch/arm/kernel/signal.c | 24 ++++++++---------------- 1 files changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 9e617bd..7cb532f 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -66,12 +66,13 @@ const unsigned long syscall_restart_code[2] = { */ asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask) { - mask &= _BLOCKABLE; - spin_lock_irq(¤t->sighand->siglock); + sigset_t blocked; + current->saved_sigmask = current->blocked; - siginitset(¤t->blocked, mask); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + + mask &= _BLOCKABLE; + siginitset(&blocked, mask); + set_current_blocked(&blocked); current->state = TASK_INTERRUPTIBLE; schedule(); @@ -280,10 +281,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf) err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); if (err == 0) { sigdelsetmask(&set, ~_BLOCKABLE); - spin_lock_irq(¤t->sighand->siglock); - current->blocked = set; - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + set_current_blocked(&set); } __get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); @@ -636,13 +634,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, /* * Block the signal if we were successful. */ - spin_lock_irq(&tsk->sighand->siglock); - sigorsets(&tsk->blocked, &tsk->blocked, - &ka->sa.sa_mask); - if (!(ka->sa.sa_flags & SA_NODEFER)) - sigaddset(&tsk->blocked, sig); - recalc_sigpending(); - spin_unlock_irq(&tsk->sighand->siglock); + block_sigmask(ka, sig); return 0; } -- 1.7.4.4
next prev parent reply other threads:[~2012-02-14 11:40 UTC|newest] Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-02-14 11:40 [PATCH 00/40] arch: set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:40 ` [PATCH 01/40] alpha: Use " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` Matt Fleming [this message] 2012-02-14 11:40 ` [PATCH 02/40] arm: " Matt Fleming 2012-02-14 11:40 ` [PATCH 03/40] avr32: Don't mask signals in the error path Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 04/40] avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 05/40] avr32: Use block_sigmask() Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 06/40] blackfin: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-16 9:28 ` Bob Liu 2012-02-14 11:40 ` [PATCH 07/40] C6X: " Matt Fleming 2012-02-14 11:40 ` [PATCH 08/40] cris: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-15 8:43 ` Jesper Nilsson 2012-02-14 11:40 ` [PATCH 09/40] frv: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 10/40] h8300: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 11/40] Hexagon: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 12/40] ia64: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 13/40] m32r: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 14/40] m68k: " Matt Fleming 2012-02-14 11:40 ` [PATCH 15/40] microblaze: Don't reimplement force_sigsegv() Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 16/40] microblaze: No need to reset handler if SA_ONESHOT Matt Fleming 2012-02-14 11:40 ` [PATCH 17/40] microblaze: Fix signal masking Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 18/40] microblaze: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 19/40] MIPS: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 20/40] mn10300: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 21/40] OpenRISC: Don't reimplement force_sigsegv() Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-15 15:40 ` Jonas Bonn 2012-02-15 15:40 ` Jonas Bonn 2012-02-15 15:49 ` Matt Fleming 2012-02-15 15:57 ` Jonas Bonn 2012-02-15 15:57 ` Jonas Bonn 2012-02-14 11:40 ` [PATCH 22/40] OpenRISC: No need to reset handler if SA_ONESHOT Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 23/40] OpenRISC: Don't mask signals if we fail to setup signal stack Matt Fleming 2012-02-14 11:40 ` [PATCH 24/40] OpenRISC: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:40 ` [PATCH 25/40] parisc: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-04-06 14:59 ` Kyle McMartin 2012-02-14 11:40 ` [PATCH 26/40] powerpc: " Matt Fleming 2012-02-14 11:40 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 27/40] [S390] Use block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 28/40] score: Don't mask signals if we fail to setup signal stack Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 29/40] score: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 30/40] sh: No need to reset handler if SA_ONESHOT Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 31/40] sh: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 32/40] sparc: Use block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-15 3:57 ` David Miller 2012-02-15 3:57 ` David Miller 2012-02-14 11:41 ` [PATCH 33/40] tile: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 34/40] um: Don't restore current->blocked on error Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 35/40] um: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 36/40] unicore32: Use block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 37/40] xtensa: Don't reimplement force_sigsegv() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 38/40] xtensa: No need to reset handler if SA_ONESHOT Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 39/40] xtensa: Don't mask signals if we fail to setup signal stack Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 11:41 ` [PATCH 40/40] xtensa: Use set_current_blocked() and block_sigmask() Matt Fleming 2012-02-14 11:41 ` Matt Fleming 2012-02-14 13:45 ` [PATCH 00/40] arch: " Mark Salter 2012-02-14 13:52 ` Matt Fleming 2012-02-14 13:58 ` Mark Salter 2012-02-14 14:08 ` Matt Fleming 2012-02-14 15:56 ` [PATCH 20/40] mn10300: Use " David Howells 2012-02-14 17:23 ` Oleg Nesterov 2012-02-14 17:59 ` Matt Fleming 2012-02-14 18:12 ` David Howells 2012-02-14 18:24 ` Oleg Nesterov 2012-02-14 18:30 ` David Howells 2012-02-14 18:30 ` David Howells 2012-02-15 11:49 ` Matt Fleming 2012-02-14 17:32 ` [PATCH 00/40] arch: " Oleg Nesterov 2012-02-15 11:47 ` Matt Fleming 2012-02-15 11:47 ` Matt Fleming
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=1329219673-28711-3-git-send-email-matt@console-pimps.org \ --to=matt@console-pimps.org \ --cc=akpm@linux-foundation.org \ --cc=arnd.bergmann@linaro.org \ --cc=dave.martin@linaro.org \ --cc=linux-arch@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=matt.fleming@intel.com \ --cc=nicolas.pitre@linaro.org \ --cc=oleg@redhat.com \ --cc=will.deacon@arm.com \ /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: linkBe 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; as well as URLs for NNTP newsgroup(s).