From: Scott Branden <scott.branden@broadcom.com> To: Luis Chamberlain <mcgrof@kernel.org>, Wolfram Sang <wsa@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, David Brown <david.brown@linaro.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, bjorn.andersson@linaro.org, Shuah Khan <skhan@linuxfoundation.org>, Arnd Bergmann <arnd@arndb.de> Cc: Mimi Zohar <zohar@linux.ibm.com>, "Rafael J . Wysocki" <rafael@kernel.org>, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>, Olof Johansson <olof@lixom.net>, Andrew Morton <akpm@linux-foundation.org>, Dan Carpenter <dan.carpenter@oracle.com>, Colin Ian King <colin.king@canonical.com>, Kees Cook <keescook@chromium.org>, Takashi Iwai <tiwai@suse.de>, linux-kselftest@vger.kernel.org, Andy Gross <agross@kernel.org>, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Scott Branden <scott.branden@broadcom.com> Subject: [PATCH v10 9/9] ima: add FIRMWARE_PARTIAL_READ support Date: Mon, 6 Jul 2020 16:23:09 -0700 Message-ID: <20200706232309.12010-10-scott.branden@broadcom.com> (raw) In-Reply-To: <20200706232309.12010-1-scott.branden@broadcom.com> Add FIRMWARE_PARTIAL_READ support for integrity measurement on partial reads of firmware files. Signed-off-by: Scott Branden <scott.branden@broadcom.com> --- security/integrity/ima/ima_main.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 15f29fed6d9f..04a431924265 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -611,6 +611,9 @@ void ima_post_path_mknod(struct dentry *dentry) */ int ima_read_file(struct file *file, enum kernel_read_file_id read_id) { + enum ima_hooks func; + u32 secid; + /* * READING_FIRMWARE_PREALLOC_BUFFER * @@ -619,11 +622,27 @@ int ima_read_file(struct file *file, enum kernel_read_file_id read_id) * of IMA's signature verification any more than when using two * buffers? */ - return 0; + if (read_id != READING_FIRMWARE_PARTIAL_READ) + return 0; + + if (!file) { + if ((ima_appraise & IMA_APPRAISE_FIRMWARE) && + (ima_appraise & IMA_APPRAISE_ENFORCE)) { + pr_err("Prevent firmware loading_store.\n"); + return -EACCES; /* INTEGRITY_UNKNOWN */ + } + return 0; + } + + func = read_idmap[read_id] ?: FILE_CHECK; + security_task_getsecid(current, &secid); + return process_measurement(file, current_cred(), secid, NULL, + 0, MAY_READ, func); } const int read_idmap[READING_MAX_ID] = { [READING_FIRMWARE] = FIRMWARE_CHECK, + [READING_FIRMWARE_PARTIAL_READ] = FIRMWARE_CHECK, [READING_FIRMWARE_PREALLOC_BUFFER] = FIRMWARE_CHECK, [READING_MODULE] = MODULE_CHECK, [READING_KEXEC_IMAGE] = KEXEC_KERNEL_CHECK, @@ -650,6 +669,9 @@ int ima_post_read_file(struct file *file, void *buf, loff_t size, enum ima_hooks func; u32 secid; + if (read_id == READING_FIRMWARE_PARTIAL_READ) + return 0; + if (!file && read_id == READING_FIRMWARE) { if ((ima_appraise & IMA_APPRAISE_FIRMWARE) && (ima_appraise & IMA_APPRAISE_ENFORCE)) { -- 2.17.1
next prev parent reply index Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-06 23:23 [PATCH v10 0/9] firmware: add request_partial_firmware_into_buf Scott Branden 2020-07-06 23:23 ` [PATCH v10 1/9] fs: move kernel_read_file* to its own include file Scott Branden 2020-07-07 23:40 ` Kees Cook 2020-07-08 3:39 ` Scott Branden 2020-07-06 23:23 ` [PATCH v10 2/9] fs: introduce kernel_pread_file* support Scott Branden 2020-07-07 23:56 ` Kees Cook 2020-07-08 0:24 ` Mimi Zohar 2020-07-08 4:01 ` Scott Branden 2020-07-08 4:41 ` Scott Branden 2020-07-06 23:23 ` [PATCH v10 3/9] firmware: add request_partial_firmware_into_buf Scott Branden 2020-07-07 23:58 ` Kees Cook 2020-07-08 4:07 ` Scott Branden 2020-07-06 23:23 ` [PATCH v10 4/9] test_firmware: add partial read support for request_firmware_into_buf Scott Branden 2020-07-07 23:59 ` Kees Cook 2020-07-08 4:09 ` Scott Branden 2020-07-06 23:23 ` [PATCH v10 5/9] firmware: test partial file reads of request_partial_firmware_into_buf Scott Branden 2020-07-06 23:23 ` [PATCH v10 6/9] bcm-vk: add bcm_vk UAPI Scott Branden 2020-07-06 23:23 ` [PATCH v10 7/9] misc: bcm-vk: add Broadcom VK driver Scott Branden 2020-07-08 0:03 ` Kees Cook 2020-07-08 4:30 ` Scott Branden 2020-07-06 23:23 ` [PATCH v10 8/9] MAINTAINERS: bcm-vk: add maintainer for Broadcom VK Driver Scott Branden 2020-07-06 23:23 ` Scott Branden [this message] 2020-07-07 3:08 ` [PATCH v10 9/9] ima: add FIRMWARE_PARTIAL_READ support Kees Cook 2020-07-07 17:13 ` Scott Branden 2020-07-07 23:36 ` Kees Cook 2020-07-08 3:35 ` Scott Branden 2020-07-08 4:38 ` [PATCH v10 0/9] firmware: add request_partial_firmware_into_buf Florian Fainelli 2020-07-08 4:51 ` Scott Branden
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200706232309.12010-10-scott.branden@broadcom.com \ --to=scott.branden@broadcom.com \ --cc=agross@kernel.org \ --cc=akpm@linux-foundation.org \ --cc=arnd@arndb.de \ --cc=bcm-kernel-feedback-list@broadcom.com \ --cc=bjorn.andersson@linaro.org \ --cc=colin.king@canonical.com \ --cc=dan.carpenter@oracle.com \ --cc=david.brown@linaro.org \ --cc=gregkh@linuxfoundation.org \ --cc=keescook@chromium.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-integrity@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-kselftest@vger.kernel.org \ --cc=linux-security-module@vger.kernel.org \ --cc=mcgrof@kernel.org \ --cc=olof@lixom.net \ --cc=rafael@kernel.org \ --cc=shuah@kernel.org \ --cc=skhan@linuxfoundation.org \ --cc=tiwai@suse.de \ --cc=viro@zeniv.linux.org.uk \ --cc=wsa@kernel.org \ --cc=zohar@linux.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
LKML Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \ linux-kernel@vger.kernel.org public-inbox-index lkml Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git