Skip to content

Commit 342edb6

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES
Smatch static checker warning: fs/ksmbd/vfs.c:1040 ksmbd_vfs_fqar_lseek() warn: no lower bound on 'length' fs/ksmbd/vfs.c:1041 ksmbd_vfs_fqar_lseek() warn: no lower bound on 'start' Fix unexpected result that could caused from negative start and length. Fixes: f441584 ("cifsd: add file operations") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 2d74ec9 commit 342edb6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7448,13 +7448,16 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id,
74487448
if (in_count == 0)
74497449
return -EINVAL;
74507450

7451+
start = le64_to_cpu(qar_req->file_offset);
7452+
length = le64_to_cpu(qar_req->length);
7453+
7454+
if (start < 0 || length < 0)
7455+
return -EINVAL;
7456+
74517457
fp = ksmbd_lookup_fd_fast(work, id);
74527458
if (!fp)
74537459
return -ENOENT;
74547460

7455-
start = le64_to_cpu(qar_req->file_offset);
7456-
length = le64_to_cpu(qar_req->length);
7457-
74587461
ret = ksmbd_vfs_fqar_lseek(fp, start, length,
74597462
qar_rsp, in_count, out_count);
74607463
if (ret && ret != -E2BIG)

0 commit comments

Comments
 (0)