netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jamal <hadi@cyberus.ca>
To: Changli Gao <xiaosuo@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
Date: Wed, 02 Jun 2010 08:20:19 -0400	[thread overview]
Message-ID: <1275481219.14363.6.camel@bigi> (raw)
In-Reply-To: <AANLkTilkweiJPmQOUv78lKL9ohZo1StzlJcBw0johYi0@mail.gmail.com>

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


  reply	other threads:[~2010-06-02 12:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-31  2:24 [PATCH] cls_u32: use skb_copy_bits() to dereference data safely Changli Gao
2010-06-01 12:34 ` jamal
2010-06-01 17:47   ` Changli Gao
2010-06-02 12:20     ` jamal [this message]
2010-06-02 12:25       ` jamal
2010-06-02 12:45         ` David Miller
2010-06-02 13:14           ` Changli Gao
2010-06-02 13:27             ` David Miller
2010-06-02 13:36             ` jamal
2010-06-02 13:43               ` Changli Gao
2010-06-02 13:48                 ` jamal
2010-06-02 13:43               ` David Miller
2010-06-02 13:47                 ` jamal
2010-06-02 12:47       ` David Miller
2010-06-02 13:17       ` Changli Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1275481219.14363.6.camel@bigi \
    --to=hadi@cyberus.ca \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=xiaosuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).