From: Eric Dumazet <eric.dumazet@gmail.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Changli Gao <xiaosuo@gmail.com>,
Patrick McHardy <kaber@trash.net>,
"David S. Miller" <davem@davemloft.net>,
netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] netfilter: check the length of the data before dereferencing it
Date: Sun, 01 Apr 2012 18:55:22 +0200 [thread overview]
Message-ID: <1333299322.2325.5277.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120401164325.GB10861@1984>
On Sun, 2012-04-01 at 18:43 +0200, Pablo Neira Ayuso wrote:
> On Sun, Apr 01, 2012 at 10:22:50PM +0800, Changli Gao wrote:
> > We should check the length of the data before dereferencing it when parsing
> > the TCP options.
> >
> > Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> > ---
> > net/netfilter/nf_conntrack_proto_tcp.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> > diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
> > index 361eade..9e446c5 100644
> > --- a/net/netfilter/nf_conntrack_proto_tcp.c
> > +++ b/net/netfilter/nf_conntrack_proto_tcp.c
> > @@ -404,6 +404,8 @@ static void tcp_options(const struct sk_buff *skb,
> > length--;
> > continue;
> > default:
> > + if (length < 2)
> > + return;
> > opsize=*ptr++;
> > if (opsize < 2) /* "silly options" */
> > return;
>
> length is always multiple of 4:
>
> int length = (tcph->doff*4) - sizeof(struct tcphdr);
> --
initial value yes, but it can change in the loop.
next prev parent reply other threads:[~2012-04-01 16:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-01 14:22 [PATCH] netfilter: check the length of the data before dereferencing it Changli Gao
2012-04-01 16:43 ` Pablo Neira Ayuso
2012-04-01 16:55 ` Eric Dumazet [this message]
2012-04-01 17:02 ` Pablo Neira Ayuso
2012-04-02 3:05 ` 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=1333299322.2325.5277.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