Skip to content

Commit

Permalink
usb: rndis_host: Secure rndis_query check against int overflow
Browse files Browse the repository at this point in the history
Variables off and len typed as uint32 in rndis_query function
are controlled by incoming RNDIS response message thus their
value may be manipulated. Setting off to a unexpectetly large
value will cause the sum with len and 8 to overflow and pass
the implemented validation step. Consequently the response
pointer will be referring to a location past the expected
buffer boundaries allowing information leakage e.g. via
RNDIS_OID_802_3_PERMANENT_ADDRESS OID.

Fixes: ddda086 ("USB: rndis_host, various cleanups")
Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
szymonh authored and davem330 committed Jan 3, 2023
1 parent 7dc6183 commit c7dd138
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/usb/rndis_host.c
Expand Up @@ -255,7 +255,8 @@ static int rndis_query(struct usbnet *dev, struct usb_interface *intf,

off = le32_to_cpu(u.get_c->offset);
len = le32_to_cpu(u.get_c->len);
if (unlikely((8 + off + len) > CONTROL_BUFFER_SIZE))
if (unlikely((off > CONTROL_BUFFER_SIZE - 8) ||
(len > CONTROL_BUFFER_SIZE - 8 - off)))
goto response_error;

if (*reply_len != -1 && len != *reply_len)
Expand Down

0 comments on commit c7dd138

Please sign in to comment.