Patchwork u32: negative offset fix

login
register
mail settings
Submitter stephen hemminger
Date Aug. 2, 2010, 11:44 p.m.
Message ID <20100802164413.6f327ce6@nehalam>
Download mbox | patch
Permalink /patch/60701/
State Accepted
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Aug. 2, 2010, 11:44 p.m.
It was possible to use a negative offset in a u32 match to reference
the ethernet header or other parts of the link layer header.
This fixes the regression caused by:

commit fbc2e7d9cf49e0bf89b9e91fd60a06851a855c5d
Author: Changli Gao <xiaosuo@gmail.com>
Date:   Wed Jun 2 07:32:42 2010 -0700

    cls_u32: use skb_header_pointer() to dereference data safely


Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
 Combines change to signed type and check in one patch.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Aug. 3, 2010, 5:08 a.m.
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 2 Aug 2010 16:44:13 -0700

> It was possible to use a negative offset in a u32 match to reference
> the ethernet header or other parts of the link layer header.
> This fixes the regression caused by:
> 
> commit fbc2e7d9cf49e0bf89b9e91fd60a06851a855c5d
> Author: Changli Gao <xiaosuo@gmail.com>
> Date:   Wed Jun 2 07:32:42 2010 -0700
> 
>     cls_u32: use skb_header_pointer() to dereference data safely
> 
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/net/sched/cls_u32.c	2010-08-02 15:02:36.778304996 -0700
+++ b/net/sched/cls_u32.c	2010-08-02 16:25:40.661661091 -0700
@@ -134,10 +134,12 @@  next_knode:
 #endif
 
 		for (i = n->sel.nkeys; i>0; i--, key++) {
-			unsigned int toff;
+			int toff = off + key->off + (off2 & key->offmask);
 			__be32 *data, _data;
+
+			if (skb_headroom(skb) + toff < 0)
+				goto out;
 
-			toff = off + key->off + (off2 & key->offmask);
 			data = skb_header_pointer(skb, toff, 4, &_data);
 			if (!data)
 				goto out;