From patchwork Fri Jun 7 21:41:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 10982785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 494F392A for ; Fri, 7 Jun 2019 21:41:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34EC628BAF for ; Fri, 7 Jun 2019 21:41:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24B9528BDB; Fri, 7 Jun 2019 21:41:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B38A828BDD for ; Fri, 7 Jun 2019 21:41:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731419AbfFGVli (ORCPT ); Fri, 7 Jun 2019 17:41:38 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:52888 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731303AbfFGVli (ORCPT ); Fri, 7 Jun 2019 17:41:38 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMcC-0007xv-9c; Fri, 07 Jun 2019 15:41:36 -0600 Received: from ip72-206-97-68.om.om.cox.net ([72.206.97.68] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMcB-0008Kv-FQ; Fri, 07 Jun 2019 15:41:36 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Deepa Dinamani , linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, e@80x24.org, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, Al Viro , Linus Torvalds , David Laight , References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> <20190606140814.GA13440@redhat.com> <87k1dxaxcl.fsf_-_@xmission.com> Date: Fri, 07 Jun 2019 16:41:23 -0500 In-Reply-To: <87k1dxaxcl.fsf_-_@xmission.com> (Eric W. Biederman's message of "Fri, 07 Jun 2019 16:39:54 -0500") Message-ID: <87ef45axa4.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1hZMcB-0008Kv-FQ;;;mid=<87ef45axa4.fsf_-_@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=72.206.97.68;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+1o+mLqXT5oq9Xv8ZmJiMeax+zJW/VDo8= X-SA-Exim-Connect-IP: 72.206.97.68 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [RFC PATCH 1/5] signal: Teach sigsuspend to use set_user_sigmask X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The sigsuspend system call overrides the signal mask just like all of the other users of set_user_sigmask, so convert it to use the same helpers. Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 6f72cff043f0..bfa36320a4f7 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2932,6 +2932,15 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset) } EXPORT_SYMBOL(sigprocmask); +static int set_sigmask(sigset_t *kmask) +{ + set_restore_sigmask(); + current->saved_sigmask = current->blocked; + set_current_blocked(kmask); + + return 0; +} + /* * The api helps set app-provided sigmasks. * @@ -2952,11 +2961,7 @@ int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize) if (copy_from_user(&kmask, umask, sizeof(sigset_t))) return -EFAULT; - set_restore_sigmask(); - current->saved_sigmask = current->blocked; - set_current_blocked(&kmask); - - return 0; + return set_sigmask(&kmask); } #ifdef CONFIG_COMPAT @@ -2972,11 +2977,7 @@ int set_compat_user_sigmask(const compat_sigset_t __user *umask, if (get_compat_sigset(&kmask, umask)) return -EFAULT; - set_restore_sigmask(); - current->saved_sigmask = current->blocked; - set_current_blocked(&kmask); - - return 0; + return set_sigmask(&kmask); } #endif @@ -4409,14 +4410,10 @@ SYSCALL_DEFINE0(pause) static int sigsuspend(sigset_t *set) { - current->saved_sigmask = current->blocked; - set_current_blocked(set); - while (!signal_pending(current)) { __set_current_state(TASK_INTERRUPTIBLE); schedule(); } - set_restore_sigmask(); return -ERESTARTNOHAND; } @@ -4430,12 +4427,10 @@ SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize) { sigset_t newset; - /* XXX: Don't preclude handling different sized sigset_t's. */ - if (sigsetsize != sizeof(sigset_t)) - return -EINVAL; - - if (copy_from_user(&newset, unewset, sizeof(newset))) + set_user_sigmask(unewset, sigsetsize); + if (!unewset) return -EFAULT; + return sigsuspend(&newset); } @@ -4444,12 +4439,10 @@ COMPAT_SYSCALL_DEFINE2(rt_sigsuspend, compat_sigset_t __user *, unewset, compat_ { sigset_t newset; - /* XXX: Don't preclude handling different sized sigset_t's. */ - if (sigsetsize != sizeof(sigset_t)) - return -EINVAL; - - if (get_compat_sigset(&newset, unewset)) + set_compat_user_sigmask(unewset, sigsetsize); + if (!unewset) return -EFAULT; + return sigsuspend(&newset); } #endif @@ -4459,6 +4452,7 @@ SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask) { sigset_t blocked; siginitset(&blocked, mask); + set_sigmask(&blocked); return sigsuspend(&blocked); } #endif @@ -4467,6 +4461,7 @@ SYSCALL_DEFINE3(sigsuspend, int, unused1, int, unused2, old_sigset_t, mask) { sigset_t blocked; siginitset(&blocked, mask); + set_sigmask(&blocked); return sigsuspend(&blocked); } #endif From patchwork Fri Jun 7 21:41:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 10982787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD97714B6 for ; Fri, 7 Jun 2019 21:42:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD15E28BDA for ; Fri, 7 Jun 2019 21:42:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0FDB28BDB; Fri, 7 Jun 2019 21:42:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B0F328BDA for ; Fri, 7 Jun 2019 21:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731324AbfFGVmN (ORCPT ); Fri, 7 Jun 2019 17:42:13 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:53098 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730065AbfFGVmN (ORCPT ); Fri, 7 Jun 2019 17:42:13 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMcl-00081M-IX; Fri, 07 Jun 2019 15:42:11 -0600 Received: from ip72-206-97-68.om.om.cox.net ([72.206.97.68] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMck-0002Ng-OJ; Fri, 07 Jun 2019 15:42:11 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Deepa Dinamani , linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, e@80x24.org, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, Al Viro , Linus Torvalds , David Laight , References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> <20190606140814.GA13440@redhat.com> <87k1dxaxcl.fsf_-_@xmission.com> Date: Fri, 07 Jun 2019 16:41:58 -0500 In-Reply-To: <87k1dxaxcl.fsf_-_@xmission.com> (Eric W. Biederman's message of "Fri, 07 Jun 2019 16:39:54 -0500") Message-ID: <878sudax95.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1hZMck-0002Ng-OJ;;;mid=<878sudax95.fsf_-_@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=72.206.97.68;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+g9ei2CqhvR0nVQpyGyzZNkV3XsxNnw0o= X-SA-Exim-Connect-IP: 72.206.97.68 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [RFC PATCH 2/5] signal/kvm: Stop using sigprocmask in kvm_sigset_(activate|deactivate) X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of jumping through hoops call __set_current_blocked directly. As well as directly manipulating real_blocked. This is in preparation for modifying the code to always keep real_blocked in sync with blocked except in the rare cases when the kernel needs to override it. Signed-off-by: "Eric W. Biederman" --- virt/kvm/kvm_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index f0d13d9d125d..8575a1010bfc 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2240,7 +2240,8 @@ void kvm_sigset_activate(struct kvm_vcpu *vcpu) * ->real_blocked don't care as long ->real_blocked is always a subset * of ->blocked. */ - sigprocmask(SIG_SETMASK, &vcpu->sigset, ¤t->real_blocked); + current->real_blocked = current->blocked; + __set_current_blocked(&vcpu->sigset); } void kvm_sigset_deactivate(struct kvm_vcpu *vcpu) @@ -2248,7 +2249,7 @@ void kvm_sigset_deactivate(struct kvm_vcpu *vcpu) if (!vcpu->sigset_active) return; - sigprocmask(SIG_SETMASK, ¤t->real_blocked, NULL); + __set_current_blocked(¤t->real_blocked); sigemptyset(¤t->real_blocked); } From patchwork Fri Jun 7 21:42:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 10982789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D431992A for ; Fri, 7 Jun 2019 21:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C111428BA6 for ; Fri, 7 Jun 2019 21:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B57E328BDA; Fri, 7 Jun 2019 21:42:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C75628BDA for ; Fri, 7 Jun 2019 21:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730078AbfFGVmx (ORCPT ); Fri, 7 Jun 2019 17:42:53 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:35017 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729731AbfFGVmx (ORCPT ); Fri, 7 Jun 2019 17:42:53 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMdP-00052p-9m; Fri, 07 Jun 2019 15:42:51 -0600 Received: from ip72-206-97-68.om.om.cox.net ([72.206.97.68] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMdN-0008Ta-Vo; Fri, 07 Jun 2019 15:42:51 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Deepa Dinamani , linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, e@80x24.org, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, Al Viro , Linus Torvalds , David Laight , References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> <20190606140814.GA13440@redhat.com> <87k1dxaxcl.fsf_-_@xmission.com> Date: Fri, 07 Jun 2019 16:42:38 -0500 In-Reply-To: <87k1dxaxcl.fsf_-_@xmission.com> (Eric W. Biederman's message of "Fri, 07 Jun 2019 16:39:54 -0500") Message-ID: <8736klax81.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1hZMdN-0008Ta-Vo;;;mid=<8736klax81.fsf_-_@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=72.206.97.68;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX196inFbSGEV5ZM/UKXy2JalQH0m48f/YkU= X-SA-Exim-Connect-IP: 72.206.97.68 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [RFC PATCH 3/5] signal: Always keep real_blocked in sync with blocked X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Except where we temporarily override blocked always keep real_blocked in sync with blocked. By always setting real_blocked when we set blocked this allows some slight efficiency and simplifications, by not having to save blocked. This also preparse the code for the removal of saved_sigmask. That should result in a massive simplification. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 1 + kernel/signal.c | 14 ++++++++++---- virt/kvm/kvm_main.c | 8 -------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 6f357f4fc859..6507d700d70f 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -968,6 +968,7 @@ int ptrace_request(struct task_struct *child, long request, */ spin_lock_irq(&child->sighand->siglock); child->blocked = new_set; + child->real_blocked = new_set; spin_unlock_irq(&child->sighand->siglock); clear_tsk_restore_sigmask(child); diff --git a/kernel/signal.c b/kernel/signal.c index bfa36320a4f7..fcd84f4a93c9 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2878,6 +2878,9 @@ void set_current_blocked(sigset_t *newset) { sigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP)); __set_current_blocked(newset); + + /* Lockless, only current can change ->real_blocked, never from irq */ + current->real_blocked = *newset; } void __set_current_blocked(const sigset_t *newset) @@ -2928,15 +2931,20 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset) } __set_current_blocked(&newset); + + /* Lockless, only current can change ->real_blocked, never from irq */ + tsk->real_blocked = newset; return 0; } EXPORT_SYMBOL(sigprocmask); -static int set_sigmask(sigset_t *kmask) +static int set_sigmask(sigset_t *newset) { set_restore_sigmask(); current->saved_sigmask = current->blocked; - set_current_blocked(kmask); + + sigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP)); + __set_current_blocked(newset); return 0; } @@ -3440,7 +3448,6 @@ static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info, * they arrive. Unblocking is always fine, we can avoid * set_current_blocked(). */ - tsk->real_blocked = tsk->blocked; sigandsets(&tsk->blocked, &tsk->blocked, &mask); recalc_sigpending(); spin_unlock_irq(&tsk->sighand->siglock); @@ -3450,7 +3457,6 @@ static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info, HRTIMER_MODE_REL); spin_lock_irq(&tsk->sighand->siglock); __set_task_blocked(tsk, &tsk->real_blocked); - sigemptyset(&tsk->real_blocked); sig = dequeue_signal(tsk, &mask, info); } spin_unlock_irq(&tsk->sighand->siglock); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 8575a1010bfc..4bfed018574a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2234,13 +2234,6 @@ void kvm_sigset_activate(struct kvm_vcpu *vcpu) if (!vcpu->sigset_active) return; - /* - * This does a lockless modification of ->real_blocked, which is fine - * because, only current can change ->real_blocked and all readers of - * ->real_blocked don't care as long ->real_blocked is always a subset - * of ->blocked. - */ - current->real_blocked = current->blocked; __set_current_blocked(&vcpu->sigset); } @@ -2250,7 +2243,6 @@ void kvm_sigset_deactivate(struct kvm_vcpu *vcpu) return; __set_current_blocked(¤t->real_blocked); - sigemptyset(¤t->real_blocked); } static void grow_halt_poll_ns(struct kvm_vcpu *vcpu) From patchwork Fri Jun 7 21:43:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 10982791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77EE914B6 for ; Fri, 7 Jun 2019 21:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 671E428BA7 for ; Fri, 7 Jun 2019 21:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ADBC28BDA; Fri, 7 Jun 2019 21:43:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E55FF28BD4 for ; Fri, 7 Jun 2019 21:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730937AbfFGVng (ORCPT ); Fri, 7 Jun 2019 17:43:36 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:53807 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730527AbfFGVng (ORCPT ); Fri, 7 Jun 2019 17:43:36 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMe6-0008BU-It; Fri, 07 Jun 2019 15:43:34 -0600 Received: from ip72-206-97-68.om.om.cox.net ([72.206.97.68] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMe5-00007T-Gx; Fri, 07 Jun 2019 15:43:34 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Deepa Dinamani , linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, e@80x24.org, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, Al Viro , Linus Torvalds , David Laight , References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> <20190606140814.GA13440@redhat.com> <87k1dxaxcl.fsf_-_@xmission.com> Date: Fri, 07 Jun 2019 16:43:21 -0500 In-Reply-To: <87k1dxaxcl.fsf_-_@xmission.com> (Eric W. Biederman's message of "Fri, 07 Jun 2019 16:39:54 -0500") Message-ID: <87wohx9ime.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1hZMe5-00007T-Gx;;;mid=<87wohx9ime.fsf_-_@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=72.206.97.68;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18P0VJzgd3V/iTMGLHkzGDAaMXjRN+/OPE= X-SA-Exim-Connect-IP: 72.206.97.68 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [RFC PATCH 4/5] signal: Remove saved_sigmask X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have real_sigmask that serves the same purpose and is always kept uptodate. Remove a field from the task structure and a conditional from the signal delivery code by removing this field. Signed-off-by: "Eric W. Biederman" --- include/linux/sched.h | 2 -- include/linux/sched/signal.h | 9 +++------ kernel/ptrace.c | 12 ++---------- kernel/signal.c | 2 -- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 11837410690f..520efbd355be 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -864,8 +864,6 @@ struct task_struct { struct sighand_struct *sighand; sigset_t blocked; sigset_t real_blocked; - /* Restored if set_restore_sigmask() was used: */ - sigset_t saved_sigmask; struct sigpending pending; unsigned long sas_ss_sp; size_t sas_ss_size; diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 97f6a6a35a81..78678de45278 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -407,7 +407,7 @@ void task_join_group_stop(struct task_struct *task); */ /** - * set_restore_sigmask() - make sure saved_sigmask processing gets done + * set_restore_sigmask() - make sure real_sigmask processing gets done * * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code * will run before returning to user mode, to process the flag. For @@ -479,7 +479,7 @@ static inline bool test_and_clear_restore_sigmask(void) static inline void restore_saved_sigmask(void) { if (test_and_clear_restore_sigmask()) - __set_current_blocked(¤t->saved_sigmask); + __set_current_blocked(¤t->real_blocked); } extern int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize); @@ -494,10 +494,7 @@ static inline void restore_saved_sigmask_unless(bool interrupted) static inline sigset_t *sigmask_to_save(void) { - sigset_t *res = ¤t->blocked; - if (unlikely(test_restore_sigmask())) - res = ¤t->saved_sigmask; - return res; + return ¤t->real_blocked; } static inline int kill_cad_pid(int sig, int priv) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 6507d700d70f..5ed6126e1cc5 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -925,26 +925,18 @@ int ptrace_request(struct task_struct *child, long request, ret = ptrace_setsiginfo(child, &siginfo); break; - case PTRACE_GETSIGMASK: { - sigset_t *mask; - + case PTRACE_GETSIGMASK: if (addr != sizeof(sigset_t)) { ret = -EINVAL; break; } - if (test_tsk_restore_sigmask(child)) - mask = &child->saved_sigmask; - else - mask = &child->blocked; - - if (copy_to_user(datavp, mask, sizeof(sigset_t))) + if (copy_to_user(datavp, &child->real_blocked, sizeof(sigset_t))) ret = -EFAULT; else ret = 0; break; - } case PTRACE_SETSIGMASK: { sigset_t new_set; diff --git a/kernel/signal.c b/kernel/signal.c index fcd84f4a93c9..c37d4f209699 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2941,8 +2941,6 @@ EXPORT_SYMBOL(sigprocmask); static int set_sigmask(sigset_t *newset) { set_restore_sigmask(); - current->saved_sigmask = current->blocked; - sigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP)); __set_current_blocked(newset); From patchwork Fri Jun 7 21:44:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 10982793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39B5F14B6 for ; Fri, 7 Jun 2019 21:44:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2624028BC4 for ; Fri, 7 Jun 2019 21:44:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19C3F28BD4; Fri, 7 Jun 2019 21:44:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C259028BD9 for ; Fri, 7 Jun 2019 21:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730976AbfFGVof (ORCPT ); Fri, 7 Jun 2019 17:44:35 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:54102 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730527AbfFGVof (ORCPT ); Fri, 7 Jun 2019 17:44:35 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMf0-0008Gk-GC; Fri, 07 Jun 2019 15:44:30 -0600 Received: from ip72-206-97-68.om.om.cox.net ([72.206.97.68] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hZMey-0002bU-DT; Fri, 07 Jun 2019 15:44:30 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Deepa Dinamani , linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, e@80x24.org, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, Al Viro , Linus Torvalds , David Laight , References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> <20190606140814.GA13440@redhat.com> <87k1dxaxcl.fsf_-_@xmission.com> Date: Fri, 07 Jun 2019 16:44:16 -0500 In-Reply-To: <87k1dxaxcl.fsf_-_@xmission.com> (Eric W. Biederman's message of "Fri, 07 Jun 2019 16:39:54 -0500") Message-ID: <87pnnp9ikv.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1hZMey-0002bU-DT;;;mid=<87pnnp9ikv.fsf_-_@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=72.206.97.68;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1990sxeGhhuls7CGjcVCFWx2AXKhNEH5eQ= X-SA-Exim-Connect-IP: 72.206.97.68 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [RFC PATCH 5/5] signal: Remove the unnecessary restore_sigmask flag X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP __set_current_blocked already has a test to see if the new value and the old value of the signal mask differ. Both real_blocked and blocked should be on the same cache line, and are a single word compare on 64bit. Historically real_blocked or saved_sigmask could be garbage so a test had to be used that always tested valid bits. Now that real_blocked is alwasy valid there is no need to test something different. Signed-off-by: "Eric W. Biederman" --- arch/arc/include/asm/thread_info.h | 1 - arch/arm/include/asm/thread_info.h | 1 - arch/arm64/include/asm/thread_info.h | 1 - arch/c6x/include/asm/thread_info.h | 1 - arch/csky/include/asm/thread_info.h | 2 - arch/h8300/include/asm/thread_info.h | 1 - arch/hexagon/include/asm/thread_info.h | 1 - arch/m68k/include/asm/thread_info.h | 1 - arch/mips/include/asm/thread_info.h | 1 - arch/nds32/include/asm/thread_info.h | 2 - arch/nios2/include/asm/thread_info.h | 2 - arch/riscv/include/asm/thread_info.h | 1 - arch/s390/include/asm/thread_info.h | 1 - arch/sparc/include/asm/thread_info_32.h | 1 - arch/um/include/asm/thread_info.h | 1 - arch/unicore32/include/asm/thread_info.h | 1 - arch/xtensa/include/asm/thread_info.h | 1 - include/linux/sched.h | 3 - include/linux/sched/signal.h | 79 +----------------------- kernel/ptrace.c | 2 - kernel/signal.c | 7 --- 21 files changed, 1 insertion(+), 110 deletions(-) diff --git a/arch/arc/include/asm/thread_info.h b/arch/arc/include/asm/thread_info.h index c85947bac5e5..bde0f76a986b 100644 --- a/arch/arc/include/asm/thread_info.h +++ b/arch/arc/include/asm/thread_info.h @@ -77,7 +77,6 @@ static inline __attribute_const__ struct thread_info *current_thread_info(void) * - pending work-to-be-done flags are in LSW * - other flags in MSW */ -#define TIF_RESTORE_SIGMASK 0 /* restore sig mask in do_signal() */ #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ #define TIF_SIGPENDING 2 /* signal pending */ #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 286eb61c632b..d1ee97031c21 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -147,7 +147,6 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, #define TIF_NOHZ 12 /* in adaptive nohz mode */ #define TIF_USING_IWMMXT 17 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ -#define TIF_RESTORE_SIGMASK 20 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index eb3ef73e07cf..bb8fdc9f78d2 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -93,7 +93,6 @@ void arch_release_task_struct(struct task_struct *tsk); #define TIF_SECCOMP 11 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_FREEZE 19 -#define TIF_RESTORE_SIGMASK 20 #define TIF_SINGLESTEP 21 #define TIF_32BIT 22 /* 32bit process */ #define TIF_SVE 23 /* Scalable Vector Extension in use */ diff --git a/arch/c6x/include/asm/thread_info.h b/arch/c6x/include/asm/thread_info.h index 59a5697fe0f3..229d365ffa9d 100644 --- a/arch/c6x/include/asm/thread_info.h +++ b/arch/c6x/include/asm/thread_info.h @@ -84,7 +84,6 @@ struct thread_info *current_thread_info(void) #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ #define TIF_SIGPENDING 2 /* signal pending */ #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ -#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ #define TIF_MEMDIE 17 /* OOM killer killed process */ diff --git a/arch/csky/include/asm/thread_info.h b/arch/csky/include/asm/thread_info.h index 0b546a55a8bf..f7261865e9dc 100644 --- a/arch/csky/include/asm/thread_info.h +++ b/arch/csky/include/asm/thread_info.h @@ -59,7 +59,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SYSCALL_AUDIT 5 /* syscall auditing */ #define TIF_POLLING_NRFLAG 16 /* poll_idle() is TIF_NEED_RESCHED */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ -#define TIF_RESTORE_SIGMASK 20 /* restore signal mask in do_signal() */ #define TIF_SECCOMP 21 /* secure computing */ #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) @@ -70,7 +69,6 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) #define _TIF_MEMDIE (1 << TIF_MEMDIE) -#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) #define _TIF_SECCOMP (1 << TIF_SECCOMP) #endif /* _ASM_CSKY_THREAD_INFO_H */ diff --git a/arch/h8300/include/asm/thread_info.h b/arch/h8300/include/asm/thread_info.h index 0cdaa302d3d2..8d5d5063628a 100644 --- a/arch/h8300/include/asm/thread_info.h +++ b/arch/h8300/include/asm/thread_info.h @@ -68,7 +68,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ #define TIF_SINGLESTEP 3 /* singlestepping active */ #define TIF_MEMDIE 4 /* is terminating due to OOM killer */ -#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ #define TIF_NOTIFY_RESUME 6 /* callback before returning to user */ #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */ diff --git a/arch/hexagon/include/asm/thread_info.h b/arch/hexagon/include/asm/thread_info.h index f41f9c6f0e31..2d1183690bc5 100644 --- a/arch/hexagon/include/asm/thread_info.h +++ b/arch/hexagon/include/asm/thread_info.h @@ -107,7 +107,6 @@ register struct thread_info *__current_thread_info asm(QUOTED_THREADINFO_REG); #define TIF_SIGPENDING 2 /* signal pending */ #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ #define TIF_SINGLESTEP 4 /* restore ss @ return to usr mode */ -#define TIF_RESTORE_SIGMASK 6 /* restore sig mask in do_signal() */ /* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 17 /* OOM killer killed process */ diff --git a/arch/m68k/include/asm/thread_info.h b/arch/m68k/include/asm/thread_info.h index 015f1ca38305..d620cb4f240e 100644 --- a/arch/m68k/include/asm/thread_info.h +++ b/arch/m68k/include/asm/thread_info.h @@ -66,6 +66,5 @@ static inline struct thread_info *current_thread_info(void) #define TIF_DELAYED_TRACE 14 /* single step a syscall */ #define TIF_SYSCALL_TRACE 15 /* syscall trace active */ #define TIF_MEMDIE 16 /* is terminating due to OOM killer */ -#define TIF_RESTORE_SIGMASK 18 /* restore signal mask in do_signal */ #endif /* _ASM_M68K_THREAD_INFO_H */ diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h index 4993db40482c..b2327b51c141 100644 --- a/arch/mips/include/asm/thread_info.h +++ b/arch/mips/include/asm/thread_info.h @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SECCOMP 4 /* secure computing */ #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */ #define TIF_UPROBE 6 /* breakpointed or singlestepping */ -#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_NOHZ 19 /* in adaptive nohz mode */ diff --git a/arch/nds32/include/asm/thread_info.h b/arch/nds32/include/asm/thread_info.h index c135111ec44e..79914ce56cd9 100644 --- a/arch/nds32/include/asm/thread_info.h +++ b/arch/nds32/include/asm/thread_info.h @@ -52,7 +52,6 @@ struct thread_info { #define TIF_POLLING_NRFLAG 17 #define TIF_MEMDIE 18 #define TIF_FREEZE 19 -#define TIF_RESTORE_SIGMASK 20 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) @@ -61,7 +60,6 @@ struct thread_info { #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) #define _TIF_FREEZE (1 << TIF_FREEZE) -#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) /* * Change these and you break ASM code in entry-common.S diff --git a/arch/nios2/include/asm/thread_info.h b/arch/nios2/include/asm/thread_info.h index 7349a4fa635b..b17309c3a5b3 100644 --- a/arch/nios2/include/asm/thread_info.h +++ b/arch/nios2/include/asm/thread_info.h @@ -86,7 +86,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_MEMDIE 4 /* is terminating due to OOM killer */ #define TIF_SECCOMP 5 /* secure computing */ #define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ -#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ @@ -97,7 +96,6 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) #define _TIF_SECCOMP (1 << TIF_SECCOMP) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) -#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) /* work to do on interrupt/exception return */ diff --git a/arch/riscv/include/asm/thread_info.h b/arch/riscv/include/asm/thread_info.h index 9c039870019b..6a1e393b4b5f 100644 --- a/arch/riscv/include/asm/thread_info.h +++ b/arch/riscv/include/asm/thread_info.h @@ -79,7 +79,6 @@ struct thread_info { #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ #define TIF_SIGPENDING 2 /* signal pending */ #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ -#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ #define TIF_MEMDIE 5 /* is terminating due to OOM killer */ #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */ #define TIF_SYSCALL_AUDIT 7 /* syscall auditing */ diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h index ce4e17c9aad6..6a1d1636016b 100644 --- a/arch/s390/include/asm/thread_info.h +++ b/arch/s390/include/asm/thread_info.h @@ -71,7 +71,6 @@ void arch_setup_new_exec(void); #define TIF_31BIT 16 /* 32bit process */ #define TIF_MEMDIE 17 /* is terminating due to OOM killer */ -#define TIF_RESTORE_SIGMASK 18 /* restore signal mask in do_signal() */ #define TIF_SINGLE_STEP 19 /* This task is single stepped */ #define TIF_BLOCK_STEP 20 /* This task is block stepped */ #define TIF_UPROBE_SINGLESTEP 21 /* This task is uprobe single stepped */ diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h index 548b366165dd..567f472c730b 100644 --- a/arch/sparc/include/asm/thread_info_32.h +++ b/arch/sparc/include/asm/thread_info_32.h @@ -103,7 +103,6 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ #define TIF_SIGPENDING 2 /* signal pending */ #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ -#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ #define TIF_USEDFPU 8 /* FPU was used by this task * this quantum (SMP) */ #define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h index 4eecd960ee8c..565b7db73083 100644 --- a/arch/um/include/asm/thread_info.h +++ b/arch/um/include/asm/thread_info.h @@ -60,7 +60,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_RESTART_BLOCK 4 #define TIF_MEMDIE 5 /* is terminating due to OOM killer */ #define TIF_SYSCALL_AUDIT 6 -#define TIF_RESTORE_SIGMASK 7 #define TIF_NOTIFY_RESUME 8 #define TIF_SECCOMP 9 /* secure computing */ diff --git a/arch/unicore32/include/asm/thread_info.h b/arch/unicore32/include/asm/thread_info.h index 5fb728f3b49a..0f38f6072839 100644 --- a/arch/unicore32/include/asm/thread_info.h +++ b/arch/unicore32/include/asm/thread_info.h @@ -119,7 +119,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 #define TIF_MEMDIE 18 -#define TIF_RESTORE_SIGMASK 20 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) diff --git a/arch/xtensa/include/asm/thread_info.h b/arch/xtensa/include/asm/thread_info.h index f092cc3f4e66..27350241615c 100644 --- a/arch/xtensa/include/asm/thread_info.h +++ b/arch/xtensa/include/asm/thread_info.h @@ -108,7 +108,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ #define TIF_SYSCALL_TRACEPOINT 4 /* syscall tracepoint instrumentation */ #define TIF_MEMDIE 5 /* is terminating due to OOM killer */ -#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ #define TIF_NOTIFY_RESUME 7 /* callback before returning to user */ #define TIF_DB_DISABLED 8 /* debug trap disabled for syscall */ diff --git a/include/linux/sched.h b/include/linux/sched.h index 520efbd355be..a5284f5ccb7c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -713,9 +713,6 @@ struct task_struct { /* Bit to tell LSMs we're in execve(): */ unsigned in_execve:1; unsigned in_iowait:1; -#ifndef TIF_RESTORE_SIGMASK - unsigned restore_sigmask:1; -#endif #ifdef CONFIG_MEMCG unsigned in_user_fault:1; #endif diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 78678de45278..ac34566e762f 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -400,86 +400,9 @@ static inline void ptrace_signal_wake_up(struct task_struct *t, bool resume) void task_join_group_stop(struct task_struct *task); -#ifdef TIF_RESTORE_SIGMASK -/* - * Legacy restore_sigmask accessors. These are inefficient on - * SMP architectures because they require atomic operations. - */ - -/** - * set_restore_sigmask() - make sure real_sigmask processing gets done - * - * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code - * will run before returning to user mode, to process the flag. For - * all callers, TIF_SIGPENDING is already set or it's no harm to set - * it. TIF_RESTORE_SIGMASK need not be in the set of bits that the - * arch code will notice on return to user mode, in case those bits - * are scarce. We set TIF_SIGPENDING here to ensure that the arch - * signal code always gets run when TIF_RESTORE_SIGMASK is set. - */ -static inline void set_restore_sigmask(void) -{ - set_thread_flag(TIF_RESTORE_SIGMASK); -} - -static inline void clear_tsk_restore_sigmask(struct task_struct *task) -{ - clear_tsk_thread_flag(task, TIF_RESTORE_SIGMASK); -} - -static inline void clear_restore_sigmask(void) -{ - clear_thread_flag(TIF_RESTORE_SIGMASK); -} -static inline bool test_tsk_restore_sigmask(struct task_struct *task) -{ - return test_tsk_thread_flag(task, TIF_RESTORE_SIGMASK); -} -static inline bool test_restore_sigmask(void) -{ - return test_thread_flag(TIF_RESTORE_SIGMASK); -} -static inline bool test_and_clear_restore_sigmask(void) -{ - return test_and_clear_thread_flag(TIF_RESTORE_SIGMASK); -} - -#else /* TIF_RESTORE_SIGMASK */ - -/* Higher-quality implementation, used if TIF_RESTORE_SIGMASK doesn't exist. */ -static inline void set_restore_sigmask(void) -{ - current->restore_sigmask = true; -} -static inline void clear_tsk_restore_sigmask(struct task_struct *task) -{ - task->restore_sigmask = false; -} -static inline void clear_restore_sigmask(void) -{ - current->restore_sigmask = false; -} -static inline bool test_restore_sigmask(void) -{ - return current->restore_sigmask; -} -static inline bool test_tsk_restore_sigmask(struct task_struct *task) -{ - return task->restore_sigmask; -} -static inline bool test_and_clear_restore_sigmask(void) -{ - if (!current->restore_sigmask) - return false; - current->restore_sigmask = false; - return true; -} -#endif - static inline void restore_saved_sigmask(void) { - if (test_and_clear_restore_sigmask()) - __set_current_blocked(¤t->real_blocked); + __set_current_blocked(¤t->real_blocked); } extern int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize); diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 5ed6126e1cc5..08e25bbb04f4 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -963,8 +963,6 @@ int ptrace_request(struct task_struct *child, long request, child->real_blocked = new_set; spin_unlock_irq(&child->sighand->siglock); - clear_tsk_restore_sigmask(child); - ret = 0; break; } diff --git a/kernel/signal.c b/kernel/signal.c index c37d4f209699..1358e6bf02d3 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2734,12 +2734,6 @@ static void signal_delivered(struct ksignal *ksig, int stepping) { sigset_t blocked; - /* A signal was successfully delivered, and the - saved sigmask was stored on the signal frame, - and will be restored by sigreturn. So we can - simply clear the restore sigmask flag. */ - clear_restore_sigmask(); - sigorsets(&blocked, ¤t->blocked, &ksig->ka.sa.sa_mask); if (!(ksig->ka.sa.sa_flags & SA_NODEFER)) sigaddset(&blocked, ksig->sig); @@ -2940,7 +2934,6 @@ EXPORT_SYMBOL(sigprocmask); static int set_sigmask(sigset_t *newset) { - set_restore_sigmask(); sigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP)); __set_current_blocked(newset);