From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: conntrack: drop malformed IPv4 packets
Date: Wed, 4 Apr 2012 13:23:39 +0200 [thread overview]
Message-ID: <20120404112339.GA3319@1984> (raw)
In-Reply-To: <1333482079.18626.323.camel@edumazet-glaptop>
On Tue, Apr 03, 2012 at 09:41:19PM +0200, Eric Dumazet wrote:
> On Tue, 2012-04-03 at 21:36 +0200, Jozsef Kadlecsik wrote:
> > It was reported that the Linux kernel sometimes logs:
> >
> > klogd: [2629147.402413] kernel BUG at net / netfilter /
> > nf_conntrack_proto_tcp.c: 447!
> > klogd: [1072212.887368] kernel BUG at net / netfilter /
> > nf_conntrack_proto_tcp.c: 392
> >
> > ipv4_get_l4proto() in nf_conntrack_l3proto_ipv4.c and tcp_error() in
> > nf_conntrack_proto_tcp.c should catch malformed packets, so the errors
> > at the indicated lines - TCP options parsing - should not happen.
> > However, tcp_error() relies on the "dataoff" offset to the TCP header,
> > calculated by ipv4_get_l4proto(). But ipv4_get_l4proto() does not check
> > bogus ihl values in IPv4 packets, which then can slip through tcp_error()
> > and get caught at the TCP options parsing routines.
> >
> > The patch fixes ipv4_get_l4proto() by dropping packets with bogus
> > ihl value.
> >
> > The patch closes netfilter bugzilla id 771.
> >
> > Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> > ---
> > net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 8 ++++++++
> > 1 files changed, 8 insertions(+), 0 deletions(-)
> >
> > diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> > index de9da21..c93d052 100644
> > --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> > +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> > @@ -84,6 +84,14 @@ static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> > *dataoff = nhoff + (iph->ihl << 2);
> > *protonum = iph->protocol;
> >
> > + /* Check bogus IP headers */
> > + if (*dataoff > skb->len) {
> > + pr_debug("nf_conntrack_ipv4: drop bogus IPv4 packet: "
> > + "nhoff %u, ihl %u, skblen %u\n",
> > + nhoff, iph->ihl << 2, skb->len);
> > + return -NF_ACCEPT;
>
> return -NF_DROP; ?
The connection tracking system should not drop packets. Well, we
sometimes do in special cases.
I think -NF_ACCEPT is fine, the user can add one rule to drop INVALID
packets (like this one) from iptables.
next prev parent reply other threads:[~2012-04-04 11:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 19:36 [PATCH 0/1] Drop malformed IPv4 packets in conntrack Jozsef Kadlecsik
2012-04-03 19:36 ` [PATCH] netfilter: conntrack: drop malformed IPv4 packets Jozsef Kadlecsik
2012-04-03 19:41 ` Eric Dumazet
2012-04-03 19:55 ` Jozsef Kadlecsik
2012-04-04 11:23 ` Pablo Neira Ayuso [this message]
2012-04-04 12:07 ` Jozsef Kadlecsik
2012-04-04 15:14 ` Pablo Neira Ayuso
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=20120404112339.GA3319@1984 \
--to=pablo@netfilter.org \
--cc=eric.dumazet@gmail.com \
--cc=kadlec@blackhole.kfki.hu \
--cc=netfilter-devel@vger.kernel.org \
/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).