Re: [syzbot] Re: [syzbot] [v9fs?] WARNING in v9fs_begin_writeback

From: syzbot
Date: Fri Aug 09 2024 - 05:20:33 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [v9fs?] WARNING in v9fs_begin_writeback
Author: lizhi.xu@xxxxxxxxxxxxx

permission not granted

#syz test: upstream c0ecd6388360

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 348cc90bf9c5..02cbc93ece5c 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <net/9p/9p.h>
#include <net/9p/client.h>
+#include <linux/security.h>

#include "v9fs.h"
#include "v9fs_vfs.h"
@@ -44,6 +45,10 @@ int v9fs_file_open(struct inode *inode, struct file *file)
struct p9_fid *fid;
int omode;

+ if ((file->f_flags & O_RDWR || file->f_flags & O_WRONLY) &&
+ security_file_permission(file, MAY_WRITE))
+ return -EPERM;
+
p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file);
v9ses = v9fs_inode2v9ses(inode);
if (v9fs_proto_dotl(v9ses))