From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f53.google.com ([74.125.83.53]:33602 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753599AbdGJH5q (ORCPT ); Mon, 10 Jul 2017 03:57:46 -0400 Received: by mail-pg0-f53.google.com with SMTP id k14so45639861pgr.0 for ; Mon, 10 Jul 2017 00:57:45 -0700 (PDT) From: Kees Cook To: Linus Torvalds Cc: Kees Cook , Andy Lutomirski , David Howells , Serge Hallyn , John Johansen , Casey Schaufler , "Eric W. Biederman" , Alexander Viro , Michal Hocko , Ben Hutchings , Hugh Dickins , Oleg Nesterov , "Jason A. Donenfeld" , Rik van Riel , James Morris , Greg Ungerer , Ingo Molnar , Nicolas Pitre , Stephen Smalley , Paul Moore , Vivek Goyal , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Tetsuo Handa , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov Subject: [PATCH v2 7/8] exec: Consolidate pdeath_signal clearing Date: Mon, 10 Jul 2017 00:57:30 -0700 Message-Id: <1499673451-66160-8-git-send-email-keescook@chromium.org> In-Reply-To: <1499673451-66160-1-git-send-email-keescook@chromium.org> References: <1499673451-66160-1-git-send-email-keescook@chromium.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Instead of an additional secureexec check for pdeath_signal, just move it up into the initial secureexec test. Neither perf nor arch code touches pdeath_signal, so the relocation shouldn't change anything. Signed-off-by: Kees Cook --- fs/exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index eeb8323977d1..e0186db02f90 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1340,6 +1340,9 @@ void setup_new_exec(struct linux_binprm * bprm) if (security_bprm_secureexec(bprm)) { /* Record for AT_SECURE. */ bprm->secureexec = 1; + + /* Make sure parent cannot signal privileged process. */ + current->pdeath_signal = 0; } arch_pick_mmap_layout(current->mm); @@ -1363,10 +1366,6 @@ void setup_new_exec(struct linux_binprm * bprm) */ current->mm->task_size = TASK_SIZE; - if (bprm->secureexec) { - current->pdeath_signal = 0; - } - /* An exec changes our domain. We are no longer part of the thread group */ current->self_exec_id++; -- 2.7.4