netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] cls_u32: signedness bug
@ 2010-10-04 12:28 Dan Carpenter
  2010-10-05  7:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-10-04 12:28 UTC (permalink / raw)
  To: Jamal Hadi Salim
  Cc: David S. Miller, Stephen Hemminger, Frans Pop, Changli Gao,
	netdev, kernel-janitors

skb_headroom() is unsigned so "skb_headroom(skb) + toff" is also
unsigned and can't be less than zero.  This test was added in 66d50d25:
"u32: negative offset fix"  It was supposed to fix a regression.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Compile tested only.  Please check.

diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 7416a5c..b0c2a82 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -137,7 +137,7 @@ next_knode:
 			int toff = off + key->off + (off2 & key->offmask);
 			__be32 *data, _data;
 
-			if (skb_headroom(skb) + toff < 0)
+			if (skb_headroom(skb) + toff > INT_MAX)
 				goto out;
 
 			data = skb_header_pointer(skb, toff, 4, &_data);

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

* Re: [patch] cls_u32: signedness bug
  2010-10-04 12:28 [patch] cls_u32: signedness bug Dan Carpenter
@ 2010-10-05  7:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-10-05  7:40 UTC (permalink / raw)
  To: error27; +Cc: hadi, shemminger, elendil, xiaosuo, netdev, kernel-janitors

From: Dan Carpenter <error27@gmail.com>
Date: Mon, 4 Oct 2010 14:28:36 +0200

> skb_headroom() is unsigned so "skb_headroom(skb) + toff" is also
> unsigned and can't be less than zero.  This test was added in 66d50d25:
> "u32: negative offset fix"  It was supposed to fix a regression.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> Compile tested only.  Please check.

This looks correct to me, thanks for fixing this.

Applied.

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

end of thread, other threads:[~2010-10-05  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-04 12:28 [patch] cls_u32: signedness bug Dan Carpenter
2010-10-05  7:40 ` 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).