From patchwork Mon Jul 31 23:51:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9873407 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 84C896016C for ; Mon, 31 Jul 2017 23:55:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DF322856D for ; Mon, 31 Jul 2017 23:55:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62A46285CC; Mon, 31 Jul 2017 23:55:33 +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=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 2DDCA285FF for ; Mon, 31 Jul 2017 23:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681AbdGaXyV (ORCPT ); Mon, 31 Jul 2017 19:54:21 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:34443 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751804AbdGaXvx (ORCPT ); Mon, 31 Jul 2017 19:51:53 -0400 Received: by mail-pg0-f52.google.com with SMTP id u185so504542pgb.1 for ; Mon, 31 Jul 2017 16:51:52 -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=dZkMELlIhihql0qUM5hNLSk1yVCk0u9EP3mVMLfpqgw=; b=UDwqPh3w274sWMR2DJb488EU2LuwzOAPyPn04wgOCfnZn19eJgsGtQrjuavOW2dwNt 2+pEARD8DRMyBJlLZs+Y2YmGrgDJqdCvLw6r1mNt0HbI6mu7IB975qsTTYF4NHRcY1Ls Nb+WZybMfvWjJWiX7FQqo53Rvq5lNWaar4Id0= 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=dZkMELlIhihql0qUM5hNLSk1yVCk0u9EP3mVMLfpqgw=; b=KHx1VFzpRPjYQZe8mbV8MjLvi4w5KCVyDBWLkJlsJmlNgdh0NLGaWpikTvDG0FP439 ldaht1UTm69qsrquRIAOrzcW5q56TjG62ZHb5VWZ2VG3Sf6mBIKMswum5eENsh+4mbl/ c4aXYFGhGlMCK60KlNafxUKKi9A4I4dqoo2IeZBJJtvAApBNWy9153HVfDcpZtKX9GHU oQ7HukXGrCLmmrdK5s1C6lnYOq0spmYnhOjsGDTZVMIj7336ECGzE5JypGVvPS9LuBs0 +tLV5rjK/LYARzmuylewiBOIcG9pn0MruQST/XVmf+tN0huuP7mY9Y2P7X1sLVYL08er rxig== X-Gm-Message-State: AIVw110qfeE785cPkxZdD002h9MpY75YKH6Ei5hofFkyZf7pvzQPrpFW GxSAmlRlGxpeFYR5 X-Received: by 10.98.202.12 with SMTP id n12mr17590123pfg.187.1501545112504; Mon, 31 Jul 2017 16:51: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 o13sm54096075pgr.40.2017.07.31.16.51.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jul 2017 16:51:47 -0700 (PDT) From: Kees Cook To: Andrew Morton Cc: Kees Cook , "Eric W . Biederman" , David Howells , 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 09/15] LSM: drop bprm_secureexec hook Date: Mon, 31 Jul 2017 16:51:27 -0700 Message-Id: <1501545093-56634-10-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 This removes the bprm_secureexec hook since the logic has been folded into the bprm_set_creds hook for all LSMs now. Cc: Eric W. Biederman Signed-off-by: Kees Cook Reviewed-by: John Johansen Acked-by: James Morris Acked-by: Serge Hallyn --- fs/exec.c | 2 -- include/linux/lsm_hooks.h | 14 +++++--------- include/linux/security.h | 7 ------- security/security.c | 5 ----- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 3762aef8b49e..f0e8d25eba9f 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1322,8 +1322,6 @@ EXPORT_SYMBOL(would_dump); void setup_new_exec(struct linux_binprm * bprm) { - bprm->secureexec |= security_bprm_secureexec(bprm); - /* * Once here, prepare_binrpm() will not be called any more, so * the final state of setuid/setgid/fscaps can be merged into the diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 080f34e66017..2ddc1c7e8923 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -40,7 +40,11 @@ * interpreters. The hook can tell whether it has already been called by * checking to see if @bprm->security is non-NULL. If so, then the hook * may decide either to retain the security information saved earlier or - * to replace it. + * to replace it. The hook must set @bprm->secureexec to 1 if a "secure + * exec" has happened as a result of this hook call. The flag is used to + * indicate the need for a sanitized execution environment, and is also + * passed in the ELF auxiliary table on the initial stack to indicate + * whether libc should enable secure mode. * @bprm contains the linux_binprm structure. * Return 0 if the hook is successful and permission is granted. * @bprm_check_security: @@ -68,12 +72,6 @@ * linux_binprm structure. This hook is a good place to perform state * changes on the process such as clearing out non-inheritable signal * state. This is called immediately after commit_creds(). - * @bprm_secureexec: - * Return a boolean value (0 or 1) indicating whether a "secure exec" - * is required. The flag is passed in the auxiliary table - * on the initial stack to the ELF interpreter to indicate whether libc - * should enable secure mode. - * @bprm contains the linux_binprm structure. * * Security hooks for filesystem operations. * @@ -1368,7 +1366,6 @@ union security_list_options { int (*bprm_set_creds)(struct linux_binprm *bprm); int (*bprm_check_security)(struct linux_binprm *bprm); - int (*bprm_secureexec)(struct linux_binprm *bprm); void (*bprm_committing_creds)(struct linux_binprm *bprm); void (*bprm_committed_creds)(struct linux_binprm *bprm); @@ -1680,7 +1677,6 @@ struct security_hook_heads { struct list_head vm_enough_memory; struct list_head bprm_set_creds; struct list_head bprm_check_security; - struct list_head bprm_secureexec; struct list_head bprm_committing_creds; struct list_head bprm_committed_creds; struct list_head sb_alloc_security; diff --git a/include/linux/security.h b/include/linux/security.h index af675b576645..133c41bb666d 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -80,7 +80,6 @@ extern int cap_capset(struct cred *new, const struct cred *old, const kernel_cap_t *inheritable, const kernel_cap_t *permitted); extern int cap_bprm_set_creds(struct linux_binprm *bprm); -extern int cap_bprm_secureexec(struct linux_binprm *bprm); extern int cap_inode_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); extern int cap_inode_removexattr(struct dentry *dentry, const char *name); @@ -223,7 +222,6 @@ int security_bprm_set_creds(struct linux_binprm *bprm); int security_bprm_check(struct linux_binprm *bprm); void security_bprm_committing_creds(struct linux_binprm *bprm); void security_bprm_committed_creds(struct linux_binprm *bprm); -int security_bprm_secureexec(struct linux_binprm *bprm); int security_sb_alloc(struct super_block *sb); void security_sb_free(struct super_block *sb); int security_sb_copy_data(char *orig, char *copy); @@ -515,11 +513,6 @@ static inline void security_bprm_committed_creds(struct linux_binprm *bprm) { } -static inline int security_bprm_secureexec(struct linux_binprm *bprm) -{ - return cap_bprm_secureexec(bprm); -} - static inline int security_sb_alloc(struct super_block *sb) { return 0; diff --git a/security/security.c b/security/security.c index b9fea3999cf8..750b83186869 100644 --- a/security/security.c +++ b/security/security.c @@ -311,11 +311,6 @@ void security_bprm_committed_creds(struct linux_binprm *bprm) call_void_hook(bprm_committed_creds, bprm); } -int security_bprm_secureexec(struct linux_binprm *bprm) -{ - return call_int_hook(bprm_secureexec, 0, bprm); -} - int security_sb_alloc(struct super_block *sb) { return call_int_hook(sb_alloc_security, 0, sb);