From: Eric Dumazet <eric.dumazet@gmail.com>
To: Changli Gao <xiaosuo@gmail.com>
Cc: David Miller <davem@davemloft.net>,
kaber@trash.net, pablo@netfilter.org,
netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] net: check the length of the data before dereferencing it
Date: Mon, 02 Apr 2012 08:43:01 +0200 [thread overview]
Message-ID: <1333348981.2325.6960.camel@edumazet-glaptop> (raw)
In-Reply-To: <CABa6K_GUMGC-cWPJyG_EcX_J3+w3cq4eZhuYqZYFgbcHHaXCNQ@mail.gmail.com>
On Mon, 2012-04-02 at 14:27 +0800, Changli Gao wrote:
> On Mon, Apr 2, 2012 at 12:54 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > On Mon, 2012-04-02 at 12:47 +0800, Changli Gao wrote:
> >
> >> Got it. Thanks. FYI, the tcp options are copied to the stack before
> >> being parsed.
> >>
> >
> > What do you mean ?
> >
> > code looks like :
> >
> > const struct tcphdr *th = tcp_hdr(skb);
> > int length = (th->doff * 4) - sizeof(struct tcphdr);
> >
> > ptr = (const unsigned char *)(th + 1);
> >
> >
> >
> > Therefore ptr points somewhere in skb->head ...
> >
> >
> >
>
> Oh, sorry. I forgot to add the condition when I wrote it down. I mean
> the code in netfilter.
>
> unsigned char buff[(15 * 4) - sizeof(struct tcphdr)];
> const unsigned char *ptr;
> int length = (tcph->doff*4) - sizeof(struct tcphdr);
>
> if (!length)
> return;
>
> ptr = skb_header_pointer(skb, dataoff + sizeof(struct tcphdr),
> length, buff);
> BUG_ON(ptr == NULL);
>
Doesnt really save us, skb_header_pointer() copies only if block not
directly and fully accessible in skb->head
So if skb->head contains exactly the tcp options, we still can read one
uninit byte.
So potential problem in netfilter too.
next prev parent reply other threads:[~2012-04-02 6:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-02 3:10 [PATCH] net: check the length of the data before dereferencing it Changli Gao
2012-04-02 3:19 ` Eric Dumazet
2012-04-02 3:29 ` David Miller
2012-04-02 3:45 ` Changli Gao
2012-04-02 3:53 ` Eric Dumazet
2012-04-02 3:57 ` David Miller
2012-04-02 3:59 ` Eric Dumazet
2012-04-02 4:47 ` Changli Gao
2012-04-02 4:54 ` Eric Dumazet
2012-04-02 6:27 ` Changli Gao
2012-04-02 6:43 ` Eric Dumazet [this message]
2012-04-02 3:45 ` Eric Dumazet
2012-04-02 3:55 ` David Miller
2012-04-02 3:58 ` Eric Dumazet
2012-04-02 4:14 ` David Miller
2012-04-02 3:19 ` David Miller
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=1333348981.2325.6960.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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