Skip to content

Commit 542027e

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: add bounds check for durable handle context
Add missing bounds check for durable handle context. Cc: stable@vger.kernel.org Reported-by: Norbert Szetei <norbert@doyensec.com> Tested-by: Norbert Szetei <norbert@doyensec.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent ae989ee commit 542027e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27082708
goto out;
27092709
}
27102710

2711+
if (le16_to_cpu(context->DataOffset) +
2712+
le32_to_cpu(context->DataLength) <
2713+
sizeof(struct create_durable_reconn_v2_req)) {
2714+
err = -EINVAL;
2715+
goto out;
2716+
}
2717+
27112718
recon_v2 = (struct create_durable_reconn_v2_req *)context;
27122719
persistent_id = recon_v2->Fid.PersistentFileId;
27132720
dh_info->fp = ksmbd_lookup_durable_fd(persistent_id);
@@ -2741,6 +2748,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27412748
goto out;
27422749
}
27432750

2751+
if (le16_to_cpu(context->DataOffset) +
2752+
le32_to_cpu(context->DataLength) <
2753+
sizeof(struct create_durable_reconn_req)) {
2754+
err = -EINVAL;
2755+
goto out;
2756+
}
2757+
27442758
recon = (struct create_durable_reconn_req *)context;
27452759
persistent_id = recon->Data.Fid.PersistentFileId;
27462760
dh_info->fp = ksmbd_lookup_durable_fd(persistent_id);
@@ -2766,6 +2780,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27662780
goto out;
27672781
}
27682782

2783+
if (le16_to_cpu(context->DataOffset) +
2784+
le32_to_cpu(context->DataLength) <
2785+
sizeof(struct create_durable_req_v2)) {
2786+
err = -EINVAL;
2787+
goto out;
2788+
}
2789+
27692790
durable_v2_blob =
27702791
(struct create_durable_req_v2 *)context;
27712792
ksmbd_debug(SMB, "Request for durable v2 open\n");

0 commit comments

Comments
 (0)