Hi Mimi,typo: "checkpatch" should be "patch diff"
On 2020-05-13 11:39 a.m., Mimi Zohar wrote:
[Cc'ing linux-security-module, linux-integrity]The checkpatch shows this as kernel_read_file when it is actually the new function kernel_pread_file.
On Thu, 2020-05-07 at 17:27 -0700, Scott Branden wrote:
Add kernel_pread_file* support to kernel to allow for partial read<snip>
of files with an offset into the file. Existing kernel_read_file
functions call new kernel_pread_file functions with offset=0 and
flags=KERNEL_PREAD_FLAG_WHOLE.
Signed-off-by: Scott Branden <scott.branden@xxxxxxxxxxxx>
---
@@ -941,14 +955,16 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size,
Please see the call to kernel_pread_file from kernel_read_file in the complete patch rather this snippet.The partial file read support is needed for request_firmware_into_buf from drivers. The EXPORT_SYMBOL_GPL is being removed so that Â if (bytes == 0)Prior to the patch set that introduced this security hook, firmware
ÂÂÂÂÂÂÂÂÂÂÂÂÂ break;
+
+ÂÂÂÂÂÂÂ buf_pos += bytes;
ÂÂÂÂÂ }
 - if (pos != i_size) {
+ÂÂÂ if (pos != read_end) {
ÂÂÂÂÂÂÂÂÂ ret = -EIO;
ÂÂÂÂÂÂÂÂÂ goto out_free;
ÂÂÂÂÂ }
 - ret = security_kernel_post_read_file(file, *buf, i_size, id);
+ÂÂÂ ret = security_kernel_post_read_file(file, *buf, alloc_size, id);
ÂÂÂÂÂ if (!ret)
ÂÂÂÂÂÂÂÂÂ *size = pos;
would be read twice, once for measuring/appraising the firmware and
again reading the file contents into memory. ÂPartial reads will break
both IMA's measuring the file and appraising the file signatures.
there can be no abuse of the partial file read support. Such file integrity checks are not needed for this use case. The partial file (firmware image) is actually downloaded in portions and verified on the device it is loaded to.
Regards,
ÂScott