Re: [PATCH 0/3] fs: reduce export usage of kerne_read*() calls

From: Mimi Zohar
Date: Fri Jun 05 2020 - 14:37:59 EST


On Fri, 2020-06-05 at 11:15 -0700, Scott Branden wrote:
> Hi Mimi,
>
> On 2020-05-23 7:52 p.m., Mimi Zohar wrote:
> > Scott, the change should be straight forward. ÂThe additional patch
> > needs to:
> > - define a new kernel_read_file_id enumeration, like
> > FIRMWARE_PARTIAL_READ.
> > - Currently ima_read_file() has a comment about pre-allocated firmware
> > buffers. ÂUpdate ima_read_file() to call process_measurement() for the
> > new enumeration FIRMWARE_PARTIAL_READ and update ima_post_read_file()
> > to return immediately.
> Should this be what is in ima_read_file?
> {
> ÂÂÂ enum ima_hooks func;
> ÂÂÂ u32 secid;

Please don't remove the existing comment.

> ÂÂÂ if (read_id != READING_FIRMWARE_PARTIAL_READ)
> ÂÂÂ ÂÂÂ return 0;
>
> ÂÂÂ if (!file) { /* should never happen */
> ÂÂÂ ÂÂÂ if (ima_appraise & IMA_APPRAISE_ENFORCE)
> ÂÂÂ ÂÂÂ ÂÂÂ return -EACCES;
> ÂÂÂ ÂÂÂ return 0;
> ÂÂÂ }

This checks for any IMA appraise rule. ÂYou want to enforce firmware
signature checking only if there is a firmware appraise rule. ÂRefer
to ima_post_read_file().

> ÂÂÂ security_task_getsecid(current, &secid);
> ÂÂÂ return process_measurement(file, current_cred(), secid, NULL,
> ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂ 0, MAY_READ, FILE_CHECK);

The read_idmap enumeration should be updated similar to the other
firmware. ÂKeep the code generic. ÂRefer to ima_post_read_file().
Âfunc will be defined as FIRMWARE_CHECK.

thanks,

Mimi