Skip to contentSkip to conversation

rndis_wlan: prevent integer overflow in indication()

PATCH Superseded Dan Carpenter 2 participants 2 messages Feb 29, 2012 – Mar 1, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 rndis_wlan: prevent integer overflow in indication()

If we pick a high value for "offset" then it could lead to an integer overflow and we would get past the check for:
if (offset + len > buflen) { ...

drivers/net/wireless/rndis_wlan.c +2 -2
index 74e2d1b..dfd76e3 100644
@@ -3043,7 +3043,7 @@ static void rndis_wlan_media_specific_indication(struct usbnet *usbdev,
 			struct rndis_indicate *msg, int buflen)
 {
 	struct ndis_80211_status_indication *indication;
-	int len, offset;
+	unsigned int len, offset;
 
 	offset = offsetof(struct rndis_indicate, status) +
 			le32_to_cpu(msg->offset);
@@ -3055,7 +3055,7 @@ static void rndis_wlan_media_specific_indication(struct usbnet *usbdev,
 		return;
 	}
 
-	if (offset + len > buflen) {
+	if (len > buflen || offset > buflen || offset + len > buflen) {
 		netdev_info(usbdev->net, "media specific indication, too large to fit to buffer (%i > %i)\n",
 			    offset + len, buflen);
 		return;
Acked-by on v1 4/4
#1 lore raw

Quoting Dan Carpenter <[email protected]>:

Quoted 3 lines

If we pick a high value for "offset" then it could lead to an integer overflow and we would get past the check for:
if (offset + len > buflen) { ...

Quoted 31 lines
drivers/net/wireless/rndis_wlan.c +1 -1
index 74e2d1b..dfd76e3 100644
@@ -3043,7 +3043,7 @@ static void  
 rndis_wlan_media_specific_indication(struct usbnet *usbdev,
 			struct rndis_indicate *msg, int buflen)
 {
 	struct ndis_80211_status_indication *indication;
-	int len, offset;
+	unsigned int len, offset;
 
 	offset = offsetof(struct rndis_indicate, status) +
drivers/net/wireless/rndis_wlan.c +1 -1
 			le32_to_cpu(msg->offset);
@@ -3055,7 +3055,7 @@ static void  
 rndis_wlan_media_specific_indication(struct usbnet *usbdev,
 		return;
 	}
 
-	if (offset + len > buflen) {
+	if (len > buflen || offset > buflen || offset + len > buflen) {
 		netdev_info(usbdev->net, "media specific indication, too large to  
 fit to buffer (%i > %i)\n",
drivers/net/wireless/rndis_wlan.c +0 -0
 			    offset + len, buflen);
 		return;