* [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA
@ 2023-03-05 12:34 Namjae Jeon
2023-03-05 12:34 ` [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES Namjae Jeon
2023-03-07 4:11 ` [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA Sergey Senozhatsky
0 siblings, 2 replies; 5+ messages in thread
From: Namjae Jeon @ 2023-03-05 12:34 UTC (permalink / raw)
To: linux-cifs
Cc: smfrench, senozhatsky, tom, atteh.mailbox, Namjae Jeon,
Dan Carpenter
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.
Fixes: b5e5f9dfc915 ("ksmbd: check invalid FileOffset and BeyondFinalZero in FSCTL_ZERO_DATA")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
fs/ksmbd/smb2pdu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index 81e987114206..b7a420e0fcc4 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES
2023-03-05 12:34 [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA Namjae Jeon
@ 2023-03-05 12:34 ` Namjae Jeon
2023-03-07 4:09 ` Sergey Senozhatsky
2023-03-07 4:11 ` [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA Sergey Senozhatsky
1 sibling, 1 reply; 5+ messages in thread
From: Namjae Jeon @ 2023-03-05 12:34 UTC (permalink / raw)
To: linux-cifs
Cc: smfrench, senozhatsky, tom, atteh.mailbox, Namjae Jeon,
Dan Carpenter
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: f44158485826 ("cifsd: add file operations")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
fs/ksmbd/smb2pdu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index b7a420e0fcc4..4af4230ab50b 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -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)
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES
2023-03-05 12:34 ` [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES Namjae Jeon
@ 2023-03-07 4:09 ` Sergey Senozhatsky
2023-03-07 7:10 ` Namjae Jeon
0 siblings, 1 reply; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-03-07 4:09 UTC (permalink / raw)
To: Namjae Jeon
Cc: linux-cifs, smfrench, senozhatsky, tom, atteh.mailbox,
Dan Carpenter
On (23/03/05 21:34), Namjae Jeon wrote:
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -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()?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA
2023-03-05 12:34 [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA Namjae Jeon
2023-03-05 12:34 ` [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES Namjae Jeon
@ 2023-03-07 4:11 ` Sergey Senozhatsky
1 sibling, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2023-03-07 4:11 UTC (permalink / raw)
To: Namjae Jeon
Cc: linux-cifs, smfrench, senozhatsky, tom, atteh.mailbox,
Dan Carpenter
On (23/03/05 21:34), Namjae Jeon wrote:
> 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.
>
> Fixes: b5e5f9dfc915 ("ksmbd: check invalid FileOffset and BeyondFinalZero in FSCTL_ZERO_DATA")
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES
2023-03-07 4:09 ` Sergey Senozhatsky
@ 2023-03-07 7:10 ` Namjae Jeon
0 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2023-03-07 7:10 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: linux-cifs, smfrench, tom, atteh.mailbox, Dan Carpenter
2023-03-07 13:09 GMT+09:00, Sergey Senozhatsky <senozhatsky@chromium.org>:
> On (23/03/05 21:34), Namjae Jeon wrote:
>> +++ b/fs/ksmbd/smb2pdu.c
>> @@ -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()?
We can:), will update it on v2.
Thanks!
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-07 7:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-05 12:34 [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA Namjae Jeon
2023-03-05 12:34 ` [PATCH 2/2] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES Namjae Jeon
2023-03-07 4:09 ` Sergey Senozhatsky
2023-03-07 7:10 ` Namjae Jeon
2023-03-07 4:11 ` [PATCH 1/2] ksmbd: add low bound validation to FSCTL_SET_ZERO_DATA Sergey Senozhatsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox