[PATCH] ksmbd: remove unreachable input length check in FSCTL_SET_SPARSE
From: Yiqing Wu
Date: Sun Nov 15 2026 - 22:23:42 EST
The FSCTL_SET_SPARSE handler checks whether a nonzero input buffer is
smaller than sizeof(struct file_sparse) before parsing it. That
structure holds a single __packed byte, so a nonzero in_buf_len is
always at least sizeof(struct file_sparse) and the condition can never
be true. GCC flags the dead test when building with W=2:
fs/smb/server/smb2pdu.c:12035:32: warning: logical and of mutually exclusive tests is always false [-Wlogical-op]
Remove the unreachable branch. A zero-length input is still handled
by the call site, which passes the local SetSparse default instead of
the request buffer.
Signed-off-by: Yiqing Wu <wuyiqing@xxxxxxxxxxxxxxxxxxxx>
---
fs/smb/server/smb2pdu.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index be226664b8af..08d10286cccf 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -12032,11 +12032,6 @@ int smb2_ioctl(struct ksmbd_work *work)
{
struct file_sparse sparse = {0};
- if (in_buf_len && in_buf_len < sizeof(struct file_sparse)) {
- ret = -EINVAL;
- goto out;
- }
-
*(u8 *)&sparse = 1;
ret = fsctl_set_sparse(work, id, in_buf_len ?
(struct file_sparse *)buffer : &sparse);
--
2.56.0