Message ID | 20200508092222.2097-3-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/11] fs: call file_{start,end}_write from __kernel_write | expand |
diff --git a/fs/read_write.c b/fs/read_write.c index d5aaf3a4198b9..d5c754080e5a5 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -505,6 +505,8 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t const char __user *p; ssize_t ret; + if (!(file->f_mode & FMODE_WRITE)) + return -EBADF; if (!(file->f_mode & FMODE_CAN_WRITE)) return -EINVAL;
We still need to check if the fѕ is open write, even for the low-level helper. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/read_write.c | 2 ++ 1 file changed, 2 insertions(+)