]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ksmbd: fix the warning from __kernel_write_iter
authorNamjae Jeon <linkinjeon@kernel.org>
Tue, 15 Apr 2025 00:31:08 +0000 (09:31 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 15 Apr 2025 03:21:26 +0000 (22:21 -0500)
[ 2110.972290] ------------[ cut here ]------------
[ 2110.972301] WARNING: CPU: 3 PID: 735 at fs/read_write.c:599 __kernel_write_iter+0x21b/0x280

This patch doesn't allow writing to directory.

Cc: stable@vger.kernel.org
Reported-by: Norbert Szetei <norbert@doyensec.com>
Tested-by: Norbert Szetei <norbert@doyensec.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/vfs.c

index 8554aa5a1059fd183cf0fed60ed38557a8c7cbe1..391d07da586c73e8cd272e1e0d58d9f01ba41c93 100644 (file)
@@ -479,7 +479,8 @@ int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
        int err = 0;
 
        if (work->conn->connection_type) {
-               if (!(fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE))) {
+               if (!(fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE)) ||
+                   S_ISDIR(file_inode(fp->filp)->i_mode)) {
                        pr_err("no right to write(%pD)\n", fp->filp);
                        err = -EACCES;
                        goto out;