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: 9849941 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 D1047600CC for ; Tue, 18 Jul 2017 22:26:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBD9628433 for ; Tue, 18 Jul 2017 22:26:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0A08285B7; Tue, 18 Jul 2017 22:26:53 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable 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 5280828433 for ; Tue, 18 Jul 2017 22:26:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752642AbdGRW0V (ORCPT ); Tue, 18 Jul 2017 18:26:21 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:36765 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752695AbdGRWZ4 (ORCPT ); Tue, 18 Jul 2017 18:25:56 -0400 Received: by mail-pf0-f169.google.com with SMTP id o88so11363750pfk.3 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=WbWclNsTD5ZkczvMN2L4mwGt0SAJfoKYUuRbKtXlsI12LJd3BwEYCV6F8XfMlcNrHr zLHgjg2VqC4PAn+V2Yu1CiZAnr8lBYHVBDzOlx4NVga1XpFu7rvVSTWjO/zC1K5/DZu+ /b6fDD2kQ5kjtIkrt1QLpi7GN+Vb5+TPEibr4v43vcml64I+pmwahssLJGThsDW1BMmf J8wPCbwuKYbEHpb7dyXbVTydpAkZCzGgRxnjCu9+xehxaAYekv2TE6EPJwNvkwQB1nhd qMSbeRnDr9ZoZDF6z/BWmF69f7iuz9cYpqTyV9PSW/+1Sl+qnvqXFwvGOv9hLf42Lv4a JLHw== X-Gm-Message-State: AIVw110CPByW1sT/uzMK8mQ/DJk05O2IDcaABI9q+nJSCh9NuTLEycXO Vl8UukS0Hwh0BeE+ 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: 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 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++;