ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA
Subsystems (2)
Namjae Jeon
maintainerPATCH 1/2 ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA
Smatch static checker warning:
fs/ksmbd/smb2pdu.c:7759 smb2_ioctl()
warn: no lower bound on 'off'
Fix unexpected result that could caused from negative off and bfz.
--- fs/ksmbd/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ksmbd/smb2pdu.c +1 -1
@@ -7757,7 +7757,7 @@ int smb2_ioctl(struct ksmbd_work *work) off =le64_to_cpu (zero_data->FileOffset); bfz =le64_to_cpu (zero_data->BeyondFinalZero); -if (off > bfz) { +if (off <0 || bfz <0 || off > bfz) { ret = -EINVAL ; goto out; }
Signature · 1 line
2.25.1
Namjae Jeon
maintainerPATCH 2/2 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.
--- fs/ksmbd/smb2pdu.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ksmbd/smb2pdu.c +5 -0
@@ -7457,6 +7457,11 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, start =le64_to_cpu (qar_req->file_offset); length =le64_to_cpu (qar_req->length); +if (start <0 || length <0 ) { +ksmbd_fd_put (work, fp); +return -EINVAL ; + } + ret =ksmbd_vfs_fqar_lseek (fp, start, length, qar_rsp, in_count, out_count);if (ret && ret != -E2BIG )
Signature · 1 line
2.25.1
Sergey Senozhatsky
reviewerRe: [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES
fs/ksmbd/smb2pdu.c static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, · line 7463
Quoted 9 lines · Namjae Jeon
+++
b/fs/ksmbd/smb2pdu.cfs/ksmbd/smb2pdu.c +4
-0@@ -7457,6 +7457,11 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, start =le64_to_cpu (qar_req->file_offset); length =le64_to_cpu (qar_req->length); +if (start <0 || length <0 ) { +ksmbd_fd_put (work, fp); +return -EINVAL ; + }
Can we do sanity checking before we ksmbd_lookup_fd_fast()?
Namjae Jeon
maintainerRe: [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES
2023-03-07 13:09 GMT+09:00, Sergey Senozhatsky <[email protected]>:
Quoted 7 lines · Namjae Jeon
Quoted 6 lines
+++
b/fs/ksmbd/smb2pdu.cfs/ksmbd/smb2pdu.c +0
-0@@ -7457,6 +7457,11 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, start =le64_to_cpu (qar_req->file_offset); length =le64_to_cpu (qar_req->length);
Quoted 6 lines
fs/ksmbd/smb2pdu.c static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, · line 7463
Quoted 4 lines
fs/ksmbd/smb2pdu.c +4
-0+if (start <0 || length <0 ) { +ksmbd_fd_put (work, fp); +return -EINVAL ; + }Can we do sanity checking before we
ksmbd_lookup_fd_fast()?
We can:), will update it on v2.
Thanks!
Quoted 1 line
Quoted 9 lines · Namjae Jeon
Smatch static checker warning:
fs/ksmbd/smb2pdu.c:7759smb2_ioctl()
warn: no lower bound on 'off'Fix unexpected result that could caused from negative off and bfz.
Fixes b5e5f9dfc915 ("ksmbd: check invalid FileOffset and BeyondFinalZero in FSCTL_ZERO_DATA")Reported-by Dan Carpenter <[email protected]>Signed-off-by Namjae Jeon <[email protected]>