Skip to content

Commit 9a63b99

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: fix potencial 32bit overflow from data area check in smb2_write
DataOffset and Length validation can be potencial 32bit overflow. This patch fix it. Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent bf8acc9 commit 9a63b99

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6197,8 +6197,7 @@ static noinline int smb2_write_pipe(struct ksmbd_work *work)
61976197
(offsetof(struct smb2_write_req, Buffer) - 4)) {
61986198
data_buf = (char *)&req->Buffer[0];
61996199
} else {
6200-
if ((le16_to_cpu(req->DataOffset) > get_rfc1002_len(req)) ||
6201-
(le16_to_cpu(req->DataOffset) + length > get_rfc1002_len(req))) {
6200+
if ((u64)le16_to_cpu(req->DataOffset) + length > get_rfc1002_len(req)) {
62026201
pr_err("invalid write data offset %u, smb_len %u\n",
62036202
le16_to_cpu(req->DataOffset),
62046203
get_rfc1002_len(req));
@@ -6356,8 +6355,7 @@ int smb2_write(struct ksmbd_work *work)
63566355
(offsetof(struct smb2_write_req, Buffer) - 4)) {
63576356
data_buf = (char *)&req->Buffer[0];
63586357
} else {
6359-
if ((le16_to_cpu(req->DataOffset) > get_rfc1002_len(req)) ||
6360-
(le16_to_cpu(req->DataOffset) + length > get_rfc1002_len(req))) {
6358+
if ((u64)le16_to_cpu(req->DataOffset) + length > get_rfc1002_len(req)) {
63616359
pr_err("invalid write data offset %u, smb_len %u\n",
63626360
le16_to_cpu(req->DataOffset),
63636361
get_rfc1002_len(req));

0 commit comments

Comments
 (0)