From patchwork Mon Jul 10 07:57:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9832503 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 84C9C60363 for ; Mon, 10 Jul 2017 07:58:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A3CC26E3A for ; Mon, 10 Jul 2017 07:58:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E21026E76; Mon, 10 Jul 2017 07:58:00 +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 DA83D2842E for ; Mon, 10 Jul 2017 07:57:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753655AbdGJH5y (ORCPT ); Mon, 10 Jul 2017 03:57:54 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:36014 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753646AbdGJH5v (ORCPT ); Mon, 10 Jul 2017 03:57:51 -0400 Received: by mail-pg0-f41.google.com with SMTP id u62so45411663pgb.3 for ; Mon, 10 Jul 2017 00:57:50 -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=eAbAAt85S6xcRYTRw9n6nwQcaA9aL2Ptt4ZwsyxypXQ=; b=P8U6ChHmrCTKe3ExbrEIL8LHXjuboJljBgn+GNL19PsoMPg64f5qFm4SK0MGh/UPaq W0YqUcXnhYE4gP9lQGbGiXAPMWtr72LPJfVi8wwgKhZWLiC/mKqBgv2lSJ8kH2+T7Dxq KIYq9x/YD8ox7QkEI85fz+PSV21Y9qiPQWYTg= 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=eAbAAt85S6xcRYTRw9n6nwQcaA9aL2Ptt4ZwsyxypXQ=; b=qykfoYa28QegfEo+PTRJbWqOfMkKW/9g/y7Y9urmp/kEpEnJmj9WJq5+vuFR7FtJz2 bAjMWzfvWlcE9S5adqP7XNVyN4iWEp8iCYnK6K+XRiXQS5a3983lae/PXvTChMdsb89e n5UKZF3WRIF+y2UlC2Qf7X2KaTrGDOD7B3qyHL32WdbuzuRlyEucDv3UvLHswGaUwcSz TBlDx0j48cw6KuUjgw22yauFuuJRqwx9+bR2W+8tg7pKwhYy0SH3fdJC8ccwgDI/88Fq 1DQm/eHr8T2HqziIOGV+T4jSIBqy0Es+jTvnUEdYd4C8pqRGVwsM9Cg5m3XxRrGoM9r5 7fLA== X-Gm-Message-State: AIVw112vLt/dCtQMybZc/ExLtRQZCbHK9iQXSYXXaZmyNNpaT7OqfHNx sjruAN8wrsns/0Ay X-Received: by 10.98.15.71 with SMTP id x68mr31207541pfi.176.1499673465237; Mon, 10 Jul 2017 00:57:45 -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 z6sm20672398pff.46.2017.07.10.00.57.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 00:57:42 -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> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499673451-66160-1-git-send-email-keescook@chromium.org> References: <1499673451-66160-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 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++;