Skip to contentSkip to conversation

drivers/net/macvtap: fix error check

PATCH In review Nicolas Kaiser 3 participants 3 messages Mar 5, 2011 – Mar 7, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/net/macvtap: fix error check

'len' is unsigned of type size_t and can't be negative.

---
 drivers/net/macvtap.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/macvtap.c +2 -1
index 5933621..fc27a99 100644
@@ -528,8 +528,9 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q,
 		vnet_hdr_len = q->vnet_hdr_sz;
 
 		err = -EINVAL;
-		if ((len -= vnet_hdr_len) < 0)
+		if (len < vnet_hdr_len)
 			goto err;
+		len -= vnet_hdr_len;
 
 		err = memcpy_fromiovecend((void *)&vnet_hdr, iv, 0,
 					   sizeof(vnet_hdr));
Signature · 1 line
1.7.3.4
maintainer
#2 lore raw

From: Arnd Bergmann <[email protected]>
Date: Mon, 7 Mar 2011 10:59:04 +0100

Quoted 11 lines · Nicolas Kaiser
Quoted 3 lines

'len' is unsigned of type size_t and can't be negative.

I think it's harmless: the worst thing that can happen is macvtap_alloc_skb() failing with ENOMEM when it gets a large argument, but we could have it in -stable just to be sure.

I'm just going to add it to net-2.6

I verified that gcc is not generating this test at all currently, so putting this into -stable is quite pointless.