All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denys Fedoryshchenko <nuclearcat@nuclearcat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Florian Westphal <fw@strlen.de>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Patrick McHardy <kaber@trash.net>,
	Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	linux-kernel@vger.kernel.org, netdev-owner@vger.kernel.org
Subject: Re: KASAN, xt_TCPMSS  finally found nasty use-after-free bug? 4.10.8
Date: Mon, 03 Apr 2017 11:10:44 +0300	[thread overview]
Message-ID: <35bef48734458fd995d9d4080da5db22@nuclearcat.com> (raw)
In-Reply-To: <1491153972.10124.14.camel@edumazet-glaptop3.roam.corp.google.com>

On 2017-04-02 20:26, Eric Dumazet wrote:
> On Sun, 2017-04-02 at 10:14 -0700, Eric Dumazet wrote:
> 
>> Could that be that netfilter does not abort earlier if TCP header is
>> completely wrong ?
>> 
> 
> Yes, I wonder if this patch would be better, unless we replicate the
> th->doff sanity check in all netfilter modules dissecting TCP frames.
> 
> diff --git a/net/netfilter/xt_tcpudp.c b/net/netfilter/xt_tcpudp.c
> index
> ade024c90f4f129a7c384e9e1cbfdb8ffe73065f..8cb4eadd5ba1c20e74bc27ee52a0bc36a5b26725
> 100644
> --- a/net/netfilter/xt_tcpudp.c
> +++ b/net/netfilter/xt_tcpudp.c
> @@ -103,11 +103,11 @@ static bool tcp_mt(const struct sk_buff *skb,
> struct xt_action_param *par)
>  	if (!NF_INVF(tcpinfo, XT_TCP_INV_FLAGS,
>  		     (((unsigned char *)th)[13] & tcpinfo->flg_mask) == 
> tcpinfo->flg_cmp))
>  		return false;
> +	if (th->doff * 4 < sizeof(_tcph)) {
> +		par->hotdrop = true;
> +		return false;
> +	}
>  	if (tcpinfo->option) {
> -		if (th->doff * 4 < sizeof(_tcph)) {
> -			par->hotdrop = true;
> -			return false;
> -		}
>  		if (!tcp_find_option(tcpinfo->option, skb, par->thoff,
>  				     th->doff*4 - sizeof(_tcph),
>  				     tcpinfo->invflags & XT_TCP_INV_OPTION,
I modified patch a little as:
if (th->doff * 4 < sizeof(_tcph)) {
  par->hotdrop = true;
  WARN_ON_ONCE(!tcpinfo->option);
  return false;
}

And it did triggered WARN once at morning, and didn't hit KASAN. I will 
run for a while more, to see if it is ok, and then if stable, will try 
to enable SFQ again.

  reply	other threads:[~2017-04-03  8:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-02  7:43 KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Denys Fedoryshchenko
2017-04-02 11:24 ` Eric Dumazet
2017-04-02 11:45   ` Florian Westphal
2017-04-02 11:51     ` Denys Fedoryshchenko
2017-04-02 11:54     ` Eric Dumazet
2017-04-02 12:19       ` Eric Dumazet
2017-04-02 12:25         ` Denys Fedoryshchenko
2017-04-02 12:32           ` Eric Dumazet
2017-04-02 16:52             ` Denys Fedoryshchenko
2017-04-02 17:14               ` Eric Dumazet
2017-04-02 17:26                 ` Eric Dumazet
2017-04-03  8:10                   ` Denys Fedoryshchenko [this message]
2017-04-03 12:09                     ` Eric Dumazet
2017-04-03 12:14                       ` Denys Fedoryshchenko
2017-04-03 12:24                         ` Eric Dumazet
2017-04-03 17:55   ` [PATCH net] netfilter: xt_TCPMSS: add more sanity tests on tcph->doff Eric Dumazet
2017-04-08 20:24     ` Pablo Neira Ayuso
2017-04-20 18:14       ` Denys Fedoryshchenko

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=35bef48734458fd995d9d4080da5db22@nuclearcat.com \
    --to=nuclearcat@nuclearcat.com \
    --cc=coreteam@netfilter.org \
    --cc=eric.dumazet@gmail.com \
    --cc=fw@strlen.de \
    --cc=kaber@trash.net \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev-owner@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.