Commit 342edb60 authored by Namjae Jeon's avatar Namjae Jeon Committed by Steve French

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: f4415848 ("cifsd: add file operations")
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 2d74ec97
...@@ -7448,13 +7448,16 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, ...@@ -7448,13 +7448,16 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id,
if (in_count == 0) if (in_count == 0)
return -EINVAL; return -EINVAL;
start = le64_to_cpu(qar_req->file_offset);
length = le64_to_cpu(qar_req->length);
if (start < 0 || length < 0)
return -EINVAL;
fp = ksmbd_lookup_fd_fast(work, id); fp = ksmbd_lookup_fd_fast(work, id);
if (!fp) if (!fp)
return -ENOENT; return -ENOENT;
start = le64_to_cpu(qar_req->file_offset);
length = le64_to_cpu(qar_req->length);
ret = ksmbd_vfs_fqar_lseek(fp, start, length, ret = ksmbd_vfs_fqar_lseek(fp, start, length,
qar_rsp, in_count, out_count); qar_rsp, in_count, out_count);
if (ret && ret != -E2BIG) if (ret && ret != -E2BIG)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment