Subject: [PATCH 3/4] u32: allow negative offset

From: Stephen Hemminger <[email-masked]>
Date: Mon, 02 Aug 2010 15:00:33 -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 <[email-masked]>
Date:   Wed Jun 2 07:32:42 2010 -0700

    cls_u32: use skb_header_pointer() to dereference data safely

Signed-off-by: Stephen Hemminger <[email-masked]>

--- a/net/sched/cls_u32.c	2010-08-01 09:26:20.734923805 -0700
+++ b/net/sched/cls_u32.c	2010-08-01 09:27:09.099851764 -0700
@@ -134,10 +134,9 @@ 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;
-
-			toff = off + key->off + (off2 & key->offmask);
+
 			data = skb_header_pointer(skb, toff, 4, &_data);
 			if (!data)
 				goto out;