Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: jamal <hidden>
Date: 2010-06-02 12:21:16
Hi Changli, On Wed, 2010-06-02 at 01:47 +0800, Changli Gao wrote:
I added the following debug code into cls_u32.c
for (i = n->sel.nkeys; i>0; i--, key++) {
+ int off;
+
+ off = key->off+(off2&key->offmask) + (ptr - skb->data);
+ if (off + 4 > skb->len)
+ printk("skb->len: %d, off: %d\n",
skb->len, off);Ok, makes more sense. And thanks for taking time to construct a meaningful example. It is not a common use - but i agree it is a bug. I am suprised we never caught this all this years and wondering why this never crashed in your example? Can we make the fix very simple please? i.e no copy bits, this is the fast path.
It isn't an optimization, but an error exit. :)
What i meant was if you can tell immediately what the maximum offset is then you dont need to go through for loop making comparison with each key. You could immediately bailout - which is an optimization ;-> cheers, jamal