From patchwork Tue Aug 1 19:16:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9875287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B05660365 for ; Tue, 1 Aug 2017 19:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D4FA2871F for ; Tue, 1 Aug 2017 19:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 421B628722; Tue, 1 Aug 2017 19:17:37 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 E2D682871F for ; Tue, 1 Aug 2017 19:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752442AbdHATRe (ORCPT ); Tue, 1 Aug 2017 15:17:34 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:36401 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752345AbdHATQx (ORCPT ); Tue, 1 Aug 2017 15:16:53 -0400 Received: by mail-pg0-f42.google.com with SMTP id v77so5942288pgb.3 for ; Tue, 01 Aug 2017 12:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CPd9OxzPY2yyK7pqH2l6MHUWa2l2NJtJ34Ga5Q0kdmU=; b=IK3d3q5Khfw0ncro+n3JEVRbUTIDIssYlZRVLH4QuIu2VFzrvPA/9ztrh1DjB7/pfW 56N5yS0ezgECtsf8+Zx0iV4+LBkYrkL3qt+biM2tqipeAbkCWs8Vl2akkxRzHEY/gstS P7sgte6VX6+YdCEmrWPkBhzey5cN+NISDYmaM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CPd9OxzPY2yyK7pqH2l6MHUWa2l2NJtJ34Ga5Q0kdmU=; b=DtYtr0+/cDwQr8SCxxBZTOEm26joLu8J0ETz4ZCqLjHNimsfeRPfkn1qH6TQu/GJSm /Z1x/ElRPO/tEZRHtNN4y47iX8qG0hbrQtKiEDJaj3ZI2sZK+4SuBIEBFdK5r19saYr9 0P7fKKR0gqJ9XLx/8xSMvoWHJh3jycmzE8juPxUOq5OW5XcVSfqpidGOyzRqLfpl7XvX edB8RcZkoMEYOsvSp4IHWmntUqVnsxTqhYVvgPJoWXZ2zfynP/6IqUvagxM4hqImwy+U 23tukXPspvc3crYHzuaBjfvSTN7w4VZ/snFCR4NMiihvqBFx11nStx2MQi2q8L0zuZOD 4Zpw== X-Gm-Message-State: AIVw11080BR0OyplJyna5v7/+BqCbcnk8PCDsAT0//nEZfSjW+DRSDkb 9UXYlKH/v6LrFZhw X-Received: by 10.99.185.16 with SMTP id z16mr19787410pge.395.1501615012782; Tue, 01 Aug 2017 12:16:52 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id z16sm57478953pgc.90.2017.08.01.12.16.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 12:16:49 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Linus Torvalds , Andrew Morton , James Morris , "Serge E. Hallyn" , Andy Lutomirski , "Eric W. Biederman" , John Johansen , Paul Moore , Casey Schaufler , Stephen Smalley , Tetsuo Handa , David Howells , linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v5 15/15] exec: Consolidate pdeath_signal clearing Date: Tue, 1 Aug 2017 12:16:38 -0700 Message-Id: <1501614998-62619-16-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501614998-62619-1-git-send-email-keescook@chromium.org> References: <1501614998-62619-1-git-send-email-keescook@chromium.org> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Serge Hallyn --- fs/exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 3235cbd85efa..01a9fb9d8ac3 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1351,6 +1351,9 @@ void setup_new_exec(struct linux_binprm * bprm) bprm->secureexec |= bprm->cap_elevated; if (bprm->secureexec) { + /* Make sure parent cannot signal privileged process. */ + current->pdeath_signal = 0; + /* * For secureexec, reset the stack limit to sane default to * avoid bad behavior from the prior rlimits. This has to @@ -1383,10 +1386,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++;