Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: jamal <hidden>
Date: 2010-06-01 12:42:10
From: jamal <hidden>
Date: 2010-06-01 12:42:10
Hi Changli, On Mon, 2010-05-31 at 10:24 +0800, Changli Gao wrote:
use skb_copy_bits() to dereference data safely the original skb->data dereference isn't safe, as there isn't any skb->len or skb_is_nonlinear() check.
I dont see any safety issue in current code in this respect. Do you have a specific scenario where this would be unsafe? We inspect in 32 bit chunks walking the packet data and stop when there is no more packet data.
skb_copy_bits() is used instead in this patch. And when the skb isn't long enough, we terminate the function u32_classify() immediately with -1.
That could be a very interesting optimization - but i see it as _very hard_ to do with current u32 given it has branching and different branches would have different lengths etc. You'd have to essentially do some math in user space as to what min length would suffice given a specified filter and pass that to the kernel. cheers, jamal