From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6E0BC433E0 for ; Wed, 13 May 2020 15:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00189206A5 for ; Wed, 13 May 2020 15:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729860AbgEMPo0 (ORCPT ); Wed, 13 May 2020 11:44:26 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:51988 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729483AbgEMPoZ (ORCPT ); Wed, 13 May 2020 11:44:25 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYtYF-0002PP-RZ; Wed, 13 May 2020 09:44:07 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jYtYE-0000QY-AN; Wed, 13 May 2020 09:44:07 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Luis Chamberlain Cc: viro@zeniv.linux.org.uk, gregkh@linuxfoundation.org, rafael@kernel.org, jeyu@kernel.org, jmorris@namei.org, keescook@chromium.org, paul@paul-moore.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, nayna@linux.ibm.com, zohar@linux.ibm.com, scott.branden@broadcom.com, dan.carpenter@oracle.com, skhan@linuxfoundation.org, geert@linux-m68k.org, tglx@linutronix.de, bauerman@linux.ibm.com, dhowells@redhat.com, linux-integrity@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200513152108.25669-1-mcgrof@kernel.org> <20200513152108.25669-3-mcgrof@kernel.org> Date: Wed, 13 May 2020 10:40:31 -0500 In-Reply-To: <20200513152108.25669-3-mcgrof@kernel.org> (Luis Chamberlain's message of "Wed, 13 May 2020 15:21:07 +0000") Message-ID: <87k11fonbk.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1jYtYE-0000QY-AN;;;mid=<87k11fonbk.fsf@x220.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18UC1Rfu06BcwNif7UO1o/2p3AxKZc4ZvA= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH 2/3] security: add symbol namespace for reading file data X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Luis Chamberlain writes: > Certain symbols are not meant to be used by everybody, the security > helpers for reading files directly is one such case. Use a symbol > namespace for them. > > This will prevent abuse of use of these symbols in places they were > not inteded to be used, and provides an easy way to audit where these > types of operations happen as a whole. Why not just remove the ability for the firmware loader to be a module? Is there some important use case that requires the firmware loader to be a module? We already compile the code in by default. So it is probably just easier to remove the modular support all together. Which would allow the export of the security hooks to be removed as well. Eric > Signed-off-by: Luis Chamberlain > --- > drivers/base/firmware_loader/fallback.c | 1 + > fs/exec.c | 2 ++ > kernel/kexec.c | 2 ++ > kernel/module.c | 2 ++ > security/security.c | 6 +++--- > 5 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c > index d9ac7296205e..b088886dafda 100644 > --- a/drivers/base/firmware_loader/fallback.c > +++ b/drivers/base/firmware_loader/fallback.c > @@ -19,6 +19,7 @@ > */ > > MODULE_IMPORT_NS(FIRMWARE_LOADER_PRIVATE); > +MODULE_IMPORT_NS(SECURITY_READ); > > extern struct firmware_fallback_config fw_fallback_config; > > diff --git a/fs/exec.c b/fs/exec.c > index 9791b9eef9ce..30bd800ab1d6 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -72,6 +72,8 @@ > > #include > > +MODULE_IMPORT_NS(SECURITY_READ); > + > int suid_dumpable = 0; > > static LIST_HEAD(formats); > diff --git a/kernel/kexec.c b/kernel/kexec.c > index f977786fe498..8d572b41a157 100644 > --- a/kernel/kexec.c > +++ b/kernel/kexec.c > @@ -19,6 +19,8 @@ > > #include "kexec_internal.h" > > +MODULE_IMPORT_NS(SECURITY_READ); > + > static int copy_user_segment_list(struct kimage *image, > unsigned long nr_segments, > struct kexec_segment __user *segments) > diff --git a/kernel/module.c b/kernel/module.c > index 80faaf2116dd..8973a463712e 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -59,6 +59,8 @@ > #include > #include "module-internal.h" > > +MODULE_IMPORT_NS(SECURITY_READ); > + > #define CREATE_TRACE_POINTS > #include > > diff --git a/security/security.c b/security/security.c > index 8ae66e4c370f..bdbd1fc5105a 100644 > --- a/security/security.c > +++ b/security/security.c > @@ -1654,7 +1654,7 @@ int security_kernel_read_file(struct file *file, enum kernel_read_file_id id) > return ret; > return ima_read_file(file, id); > } > -EXPORT_SYMBOL_GPL(security_kernel_read_file); > +EXPORT_SYMBOL_NS_GPL(security_kernel_read_file, SECURITY_READ); > > int security_kernel_post_read_file(struct file *file, char *buf, loff_t size, > enum kernel_read_file_id id) > @@ -1666,7 +1666,7 @@ int security_kernel_post_read_file(struct file *file, char *buf, loff_t size, > return ret; > return ima_post_read_file(file, buf, size, id); > } > -EXPORT_SYMBOL_GPL(security_kernel_post_read_file); > +EXPORT_SYMBOL_NS_GPL(security_kernel_post_read_file, SECURITY_READ); > > int security_kernel_load_data(enum kernel_load_data_id id) > { > @@ -1677,7 +1677,7 @@ int security_kernel_load_data(enum kernel_load_data_id id) > return ret; > return ima_load_data(id); > } > -EXPORT_SYMBOL_GPL(security_kernel_load_data); > +EXPORT_SYMBOL_NS_GPL(security_kernel_load_data, SECURITY_READ); > > int security_task_fix_setuid(struct cred *new, const struct cred *old, > int flags)