Re: [PATCH] vfs: Check fd has read access in kernel_read_file_from_fd()

From
Kees Cook <hidden>
Date
2021-10-07 23:39:19
Also in
linux-fsdevel
Reply to
Matthew Wilcox (Oracle), 2021-10-07
On Thu, Oct 07, 2021 at 11:01:10PM +0100, Matthew Wilcox (Oracle) wrote:
If we open a file without read access and then pass the fd to a syscall
whose implementation calls kernel_read_file_from_fd(), we get a warning
from __kernel_read():

        if (WARN_ON_ONCE(!(file->f_mode & FMODE_READ)))

This currently affects both finit_module() and kexec_file_load(), but
it could affect other syscalls in the future.

Reported-by: Hao Sun <redacted>
Fixes: b844f0ecbc56 ("vfs: define kernel_copy_file_from_fd()")
Cc: <redacted>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Kees Cook <redacted>

Thanks for chasing this down!

-- 
Kees Cook
Thread (3 messages) 3 messages, 3 authors, last reply 2021-10-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help