fs/kernel_file_read: Add "offset" arg for partial reads
To perform partial reads, callers of kernel_read_file*() must have a non-NULL file_size argument and a preallocated buffer. The new "offset" argument can then be used to seek to specific locations in the file to fill the buffer to, at most, "buf_size" per call. Where possible, the LSM hooks can report whether a full file has been read or not so that the contents can be reasoned about. Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20201002173828.2099543-14-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
34736daeec
commit
0fa8e08464
@@ -221,7 +221,7 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd,
|
||||
int ret;
|
||||
void *ldata;
|
||||
|
||||
ret = kernel_read_file_from_fd(kernel_fd, &image->kernel_buf,
|
||||
ret = kernel_read_file_from_fd(kernel_fd, 0, &image->kernel_buf,
|
||||
INT_MAX, NULL, READING_KEXEC_IMAGE);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@@ -241,7 +241,7 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd,
|
||||
#endif
|
||||
/* It is possible that there no initramfs is being loaded */
|
||||
if (!(flags & KEXEC_FILE_NO_INITRAMFS)) {
|
||||
ret = kernel_read_file_from_fd(initrd_fd, &image->initrd_buf,
|
||||
ret = kernel_read_file_from_fd(initrd_fd, 0, &image->initrd_buf,
|
||||
INT_MAX, NULL,
|
||||
READING_KEXEC_INITRAMFS);
|
||||
if (ret < 0)
|
||||
|
Reference in New Issue
Block a user