From patchwork Mon Jul 31 23:51:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9873357 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 5FE1C603B4 for ; Mon, 31 Jul 2017 23:53:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43EF028599 for ; Mon, 31 Jul 2017 23:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3896B285D3; Mon, 31 Jul 2017 23:53:27 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 CE868280CF for ; Mon, 31 Jul 2017 23:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbdGaXwZ (ORCPT ); Mon, 31 Jul 2017 19:52:25 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:37198 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751704AbdGaXv4 (ORCPT ); Mon, 31 Jul 2017 19:51:56 -0400 Received: by mail-pg0-f53.google.com with SMTP id y129so459935pgy.4 for ; Mon, 31 Jul 2017 16:51:56 -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=hnZIplJdS7QFgjsEOjo1Kf/yczsF+xc869cmTk3VHi8=; b=VDxU8HmftXXHqwAGYwjxmNc4b5J/oRY/Vx65xwj8LuBNLCXkCH9vtNYzlhlRgSY+fl 9hTl0ybBQAtukCiU62DO0ySjs/hg0VHTEKTUDvltmobT5mxAMtX0F4ichflFKz/EYRoQ cuD2LvsqTM1dPc5imzi0OQtpYY80JkKOFGJ3Y= 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=hnZIplJdS7QFgjsEOjo1Kf/yczsF+xc869cmTk3VHi8=; b=h3aoRk+KVYURL6ydVQf+69LdfKHdkENazgEBGM0Dn1atFkQryqkHS+9Yls30/gTYRx jZhRB9nurzSVJ6PIqRbyopYv6IdiU9viVa2eisVVYW+2/wfeuU/UX32CalvSbWWNVVnL f0hIbzFRRtedCCujP37F5PLgdndYHEAF2YIG7033aZQ0OQ+cTvz3ISSLDc1ungDy3p+u FNYG8KGu4lk1hTJ8u4wyvP1tPTNg4ACId4rwr8nqaoNVLSLHr08+RJ3KC9sFZkGUvimO ANlKg+qohDNXdx5Sdkmqt0mFiFunckIxG7Z8bo1B7/tJqo4r3QfOdKeQyDhtihw4ttbX qtyQ== X-Gm-Message-State: AIVw111TPMjFuVG0JVwzhI51nJ9sPAuMX1mLFUdf8U4CIDmU2waBxgXe XfT9B207kcHNUSIP X-Received: by 10.99.170.75 with SMTP id x11mr17010559pgo.140.1501545116024; Mon, 31 Jul 2017 16:51:56 -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 e131sm49961725pgc.64.2017.07.31.16.51.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jul 2017 16:51:53 -0700 (PDT) From: Kees Cook To: Andrew Morton Cc: Kees Cook , David Howells , "Eric W. Biederman" , John Johansen , "Serge E. Hallyn" , Paul Moore , Stephen Smalley , Casey Schaufler , Tetsuo Handa , James Morris , Andy Lutomirski , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 15/15] exec: Consolidate pdeath_signal clearing Date: Mon, 31 Jul 2017 16:51:33 -0700 Message-Id: <1501545093-56634-16-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501545093-56634-1-git-send-email-keescook@chromium.org> References: <1501545093-56634-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 Reviewed-by: James Morris --- fs/exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index cddd2a2cbc1f..5a19912a4f53 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1330,6 +1330,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 @@ -1362,10 +1365,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++;