[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200513065656.2110441-6-hch@lst.de>
Date: Wed, 13 May 2020 08:56:47 +0200
From: Christoph Hellwig <hch@....de>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Ian Kent <raven@...maw.net>, David Howells <dhowells@...hat.com>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-security-module@...r.kernel.org,
netfilter-devel@...r.kernel.org
Subject: [PATCH 05/14] fs: check FMODE_WRITE in __kernel_write
We still need to check if the fѕ is open write, even for the low-level
helper.
Signed-off-by: Christoph Hellwig <hch@....de>
---
fs/read_write.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/read_write.c b/fs/read_write.c
index 2c601d853ff3d..76be155ad9824 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;
--
2.26.2
Powered by blists - more mailing lists