Skip to content

Commit c7dd138

Browse files
szymonhdavem330
authored andcommitted
usb: rndis_host: Secure rndis_query check against int overflow
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7dc6183 commit c7dd138

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/usb/rndis_host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ static int rndis_query(struct usbnet *dev, struct usb_interface *intf,
255255

256256
off = le32_to_cpu(u.get_c->offset);
257257
len = le32_to_cpu(u.get_c->len);
258-
if (unlikely((8 + off + len) > CONTROL_BUFFER_SIZE))
258+
if (unlikely((off > CONTROL_BUFFER_SIZE - 8) ||
259+
(len > CONTROL_BUFFER_SIZE - 8 - off)))
259260
goto response_error;
260261

261262
if (*reply_len != -1 && len != *reply_len)

0 commit comments

Comments
 (0)