Skip to content

Commit d6ef5af

Browse files
griffinkhgregkh
authored andcommitted
usb: gadget: function: rndis: add length check for header
commit 21b5bf1 upstream. Add a length check for the rndis header in rndis_rm_hdr, to ensure that MessageType, MessageLength, DataOffset, and DataLength fields are present before they are accessed. Assisted-by: gkh_clanker_2000 Cc: stable <stable@kernel.org> Signed-off-by: Griffin Kroah-Hartman <griffin@kroah.com> Link: https://patch.msgid.link/20260708-usb-gadget-rndis-v1-2-e77e026dcc6a@kroah.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent caea8b1 commit d6ef5af

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/usb/gadget/function/rndis.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,12 @@ int rndis_rm_hdr(struct gether *port,
10801080
/* tmp points to a struct rndis_packet_msg_type */
10811081
__le32 *tmp = (void *)skb->data;
10821082

1083+
/* Need at least MessageType, MessageLength, DataOffset, DataLength */
1084+
if (skb->len < 16) {
1085+
dev_kfree_skb_any(skb);
1086+
return -EINVAL;
1087+
}
1088+
10831089
/* MessageType, MessageLength */
10841090
if (cpu_to_le32(RNDIS_MSG_PACKET)
10851091
!= get_unaligned(tmp++)) {

0 commit comments

Comments
 (0)