On Mon, Jul 06, 2020 at 04:23:09PM -0700, Scott Branden wrote:Does your patch series "Fix misused kernel_read_file() enums" handle this
Add FIRMWARE_PARTIAL_READ support for integrityHi,
measurement on partial reads of firmware files.
Several versions ago I'd suggested that the LSM infrastructure handle
the "full read" semantics so that individual LSMs don't need to each
duplicate the same efforts. As it happens, only IMA is impacted (SELinux
ignores everything except modules, and LoadPin only cares about origin
not contents).
It does not appear there is any user of partial reads of kexec images?
Next is the problem that enum kernel_read_file_id is an object
TYPE enum, not a HOW enum. (And it seems I missed the addition of
READING_FIRMWARE_PREALLOC_BUFFER, which may share a similar problem.)
That it's a partial read doesn't change _what_ you're reading: that's an
internal API detail. What happens when I attempt to do a partial read of
a kexec image?
I'll use kernel_pread_file() and pass READING_KEXEC_IMAGE,The addition I am adding is for request_partial_firmware_into_buf.
but the LSMs will have no idea it's a partial read.
The request is for a partial read. IMA ensures the whole file integrity even though I only do a partial read.
Finally, what keeps the contents of the file from changing between the
first call (which IMA will read the entire file for) and the next reads
which will bypass IMA?
I'd suggested that the open file must have writesThe file will be reopened and integrity checked on the next partial read (if there is one).
disabled on it (as execve() does).
I used existing infrastructure provided by Mimi but now looks like it will have to fit with your patches from yesterday.
So, please redesign this:
- do not add an enum
- make the file unwritable for the life of having the handle openIt's no different than a full file read so no change to be made here.
- make the "full read" happen as part of the first partial read so theEach partial read is an individual operation so I think a "full read" is performed every time
LSMs don't have to reimplement everything
Regards,
-Kees