From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf] netfilter: bridge: don't leak skb in error paths
Date: Thu, 2 Jul 2015 14:59:44 +0200 [thread overview]
Message-ID: <20150702125944.GA22321@salvia> (raw)
In-Reply-To: <1435696071-26841-1-git-send-email-fw@strlen.de>
On Tue, Jun 30, 2015 at 10:27:51PM +0200, Florian Westphal wrote:
> br_nf_dev_queue_xmit must free skb in its error path.
> NF_DROP is misleading -- its an okfn, not a netfilter hook.
Good catch.
> Fixes: 462fb2af9788a ("bridge : Sanitize skb before it enters the IP stack")
> Fixes: efb6de9b4ba00 ("netfilter: bridge: forward IPv6 fragmented packets")
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> Not sure the br_validate* calls are needed. When we reach br_nf_dev_queue_xmit
> skbs have already been through all brnf hooks where we also have these checks.
Locally originated traffic should be sane at this point, and forwarded
traffic was already validated.
> diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
> index d89f4fa..1a6fa67 100644
> --- a/net/bridge/br_netfilter_hooks.c
> +++ b/net/bridge/br_netfilter_hooks.c
> @@ -742,7 +742,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
> struct brnf_frag_data *data;
>
> if (br_validate_ipv4(skb))
> - return NF_DROP;
> + goto drop;
>
> IPCB(skb)->frag_max_size = nf_bridge->frag_max_size;
>
> @@ -767,7 +767,7 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
> struct brnf_frag_data *data;
>
> if (br_validate_ipv6(skb))
> - return NF_DROP;
> + goto drop;
>
> IP6CB(skb)->frag_max_size = nf_bridge->frag_max_size;
>
> @@ -782,12 +782,16 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
>
> if (v6ops)
> return v6ops->fragment(sk, skb, br_nf_push_frag_xmit);
> - else
> - return -EMSGSIZE;
> +
> + kfree_skb(skb);
> + return -EMSGSIZE;
> }
> #endif
> nf_bridge_info_free(skb);
> return br_dev_queue_push_xmit(sk, skb);
> + drop:
> + kfree_skb(skb);
> + return 0;
> }
>
> /* PF_BRIDGE/POST_ROUTING ********************************************/
> --
> 2.0.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-07-02 12:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 20:27 [PATCH nf] netfilter: bridge: don't leak skb in error paths Florian Westphal
2015-07-02 12:59 ` Pablo Neira Ayuso [this message]
2015-07-02 18:29 ` 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=20150702125944.GA22321@salvia \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--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).