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 #include #include +#include #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))