[PATCH 01/11] fs: call file_{start,end}_write from __kernel_write
Christoph Hellwig
hch at lst.de
Fri May 8 09:22:12 UTC 2020
We always need to take a reference on the file system we are writing
to.
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
fs/read_write.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/read_write.c b/fs/read_write.c
index bbfa9b12b15eb..d5aaf3a4198b9 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -508,6 +508,7 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t
if (!(file->f_mode & FMODE_CAN_WRITE))
return -EINVAL;
+ file_start_write(file);
old_fs = get_fs();
set_fs(KERNEL_DS);
p = (__force const char __user *)buf;
@@ -520,6 +521,7 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t
add_wchar(current, ret);
}
inc_syscw(current);
+ file_end_write(file);
return ret;
}
EXPORT_SYMBOL(__kernel_write);
--
2.26.2
More information about the Linux-security-module-archive
mailing list