Commit b26dd836 authored by Szymon Heidrich's avatar Szymon Heidrich Committed by zhaoxiaoqiang11
Browse files

usb: rndis_host: Secure rndis_query check against int overflow

stable inclusion
from stable-v5.10.163
commit 232ef345e5d76e5542f430a29658a85dbef07f0b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7PJ9N

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=232ef345e5d76e5542f430a29658a85dbef07f0b



----------------------------------------------------

[ Upstream commit c7dd1380 ]

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: ddda0862 ("USB: rndis_host, various cleanups")
Signed-off-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent 5ed59493
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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)