Skip to content

Commit f0db3d9

Browse files
namjaejeongregkh
authored andcommitted
ksmbd: add bounds check for durable handle context
commit 542027e upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c5961f6 commit f0db3d9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27042704
goto out;
27052705
}
27062706

2707+
if (le16_to_cpu(context->DataOffset) +
2708+
le32_to_cpu(context->DataLength) <
2709+
sizeof(struct create_durable_reconn_v2_req)) {
2710+
err = -EINVAL;
2711+
goto out;
2712+
}
2713+
27072714
recon_v2 = (struct create_durable_reconn_v2_req *)context;
27082715
persistent_id = recon_v2->Fid.PersistentFileId;
27092716
dh_info->fp = ksmbd_lookup_durable_fd(persistent_id);
@@ -2737,6 +2744,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27372744
goto out;
27382745
}
27392746

2747+
if (le16_to_cpu(context->DataOffset) +
2748+
le32_to_cpu(context->DataLength) <
2749+
sizeof(struct create_durable_reconn_req)) {
2750+
err = -EINVAL;
2751+
goto out;
2752+
}
2753+
27402754
recon = (struct create_durable_reconn_req *)context;
27412755
persistent_id = recon->Data.Fid.PersistentFileId;
27422756
dh_info->fp = ksmbd_lookup_durable_fd(persistent_id);
@@ -2762,6 +2776,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27622776
goto out;
27632777
}
27642778

2779+
if (le16_to_cpu(context->DataOffset) +
2780+
le32_to_cpu(context->DataLength) <
2781+
sizeof(struct create_durable_req_v2)) {
2782+
err = -EINVAL;
2783+
goto out;
2784+
}
2785+
27652786
durable_v2_blob =
27662787
(struct create_durable_req_v2 *)context;
27672788
ksmbd_debug(SMB, "Request for durable v2 open\n");

0 commit comments

Comments
 (0)