netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/net/macvtap: fix error check
@ 2011-03-04 23:49 Nicolas Kaiser
  2011-03-07  9:59 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Kaiser @ 2011-03-04 23:49 UTC (permalink / raw)
  To: David S. Miller; +Cc: Arnd Bergmann, Eric Dumazet, netdev, linux-kernel

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

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
---
 drivers/net/macvtap.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 5933621..fc27a99 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -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));
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/net/macvtap: fix error check
  2011-03-04 23:49 [PATCH] drivers/net/macvtap: fix error check Nicolas Kaiser
@ 2011-03-07  9:59 ` Arnd Bergmann
  2011-03-07 23:58   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2011-03-07  9:59 UTC (permalink / raw)
  To: Nicolas Kaiser; +Cc: David S. Miller, Eric Dumazet, netdev, linux-kernel

On Saturday 05 March 2011, Nicolas Kaiser wrote:
> 'len' is unsigned of type size_t and can't be negative.
> 
> Signed-off-by: Nicolas Kaiser <nikai@nikai.net>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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.

	Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/net/macvtap: fix error check
  2011-03-07  9:59 ` Arnd Bergmann
@ 2011-03-07 23:58   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-03-07 23:58 UTC (permalink / raw)
  To: arnd; +Cc: nikai, eric.dumazet, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 7 Mar 2011 10:59:04 +0100

> On Saturday 05 March 2011, Nicolas Kaiser wrote:
>> 'len' is unsigned of type size_t and can't be negative.
>> 
>> Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> 
> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-07 23:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-04 23:49 [PATCH] drivers/net/macvtap: fix error check Nicolas Kaiser
2011-03-07  9:59 ` Arnd Bergmann
2011-03-07 23:58   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).