]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:49 +0000 (10:45 +0200)
commit b37f2f332b40ad1c27f18682a495850f2f04db0a upstream.

[ 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/server/vfs.c

index d0c19ad9d0145c486a9054660db74fb3455f753c..fa5b7e63eb832e20a0b3d2f7a96a54ec2921dac0 100644 (file)
@@ -496,7 +496,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;