From 31169f41778a08407af332df6a32e9a1a4e5807e Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Wed, 8 Jul 2026 22:17:44 +0900 Subject: [PATCH] ksmbd: reject FSCTL_SET_SPARSE on directories FSCTL_SET_SPARSE applies to files. Return STATUS_INVALID_PARAMETER when a client sends it for a directory handle instead of setting the sparse file attribute on the directory. Signed-off-by: Namjae Jeon --- fs/smb/server/smb2pdu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 4dce10b83527..ab3ad2a358cc 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -9169,6 +9169,11 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, if (!fp) return -ENOENT; + if (S_ISDIR(file_inode(fp->filp)->i_mode)) { + ret = -EINVAL; + goto out; + } + if (!(fp->daccess & (FILE_WRITE_DATA_LE | FILE_WRITE_ATTRIBUTES_LE))) { ret = -EACCES; goto out;