From patchwork Tue Jul 18 22:25:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9849939 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 22D93600CC for ; Tue, 18 Jul 2017 22:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D4DE28433 for ; Tue, 18 Jul 2017 22:26:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01FDD285B7; Tue, 18 Jul 2017 22:26:51 +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 9900528433 for ; Tue, 18 Jul 2017 22:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752695AbdGRW0V (ORCPT ); Tue, 18 Jul 2017 18:26:21 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34399 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752697AbdGRWZ4 (ORCPT ); Tue, 18 Jul 2017 18:25:56 -0400 Received: by mail-pf0-f171.google.com with SMTP id q85so17775710pfq.1 for ; Tue, 18 Jul 2017 15:25: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=o8217eATGfZPbJQ06hvC1P6TuLaInd3bCkuda4vk8eM=; b=fPW93Ntg3E2KZlWUi3q0emDtaYSbE4nlHlnvNrp98pgJkxLRuSUUBhPe0+S8yZJP4e LJt9DjfLJ6t6Be7lE/sSrYtsDQLW97nZW9aWlw8Ykv6/bFaOVCY4YymlGSdRCbP6SvwT wA5Rh5cBAYjzYT+kg0PrdR1Ub9zLzx7boN3Tg= 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=o8217eATGfZPbJQ06hvC1P6TuLaInd3bCkuda4vk8eM=; b=HQExqN0hEzWttkViX+EHvq+nrR+RWHyXhnrHAQsF3hCgYAHT4/lyDxxzyU5pe3i4U1 sl5G3sIqYnroUfzm+kEPCGDWI4CZ7hF0CXX/v0NndMcGM0jkiVMa8FByctzw5hpM0qiy dUATjWTc6z5PWeN2vRgoE4OIXFVGaKI/e2hKsMmOarYDUsUeIoid36H+e09AFnOVf2vO 3unQK9vA407yFUopxYHmNss0wJdklz+lDvPMZ7RoH66XOkEBG/cET+2GoGASGHEFQrAl LOMukux8bt4heE/D1zLKrqWTdHLFgmNbJK2GnD2KpqGD9wsu1YCP+M6aAWiMvnqAb5+b Kqdw== X-Gm-Message-State: AIVw1133rT0LB23y4JMz3oXq5dTtl+3crIw/bAe05Y4u2e8fkKarNbyL GwBwyTc8I3PtdoBD X-Received: by 10.99.62.65 with SMTP id l62mr3904368pga.220.1500416755960; Tue, 18 Jul 2017 15:25:55 -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 r17sm7009044pfk.73.2017.07.18.15.25.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jul 2017 15:25:52 -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 v3 15/15] exec: Consolidate pdeath_signal clearing Date: Tue, 18 Jul 2017 15:25:36 -0700 Message-Id: <1500416736-49829-16-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500416736-49829-1-git-send-email-keescook@chromium.org> References: <1500416736-49829-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 --- fs/exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 4227c1e56566..9525ac15b897 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1350,6 +1350,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 @@ -1382,10 +1385,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++;