From: Florian Westphal <fw@strlen.de>
To: Rundong Ge <rdong.ge@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
kadlec@blackhole.kfki.hu, fw@strlen.de,
Roopa Prabhu <roopa@cumulusnetworks.com>,
davem@davemloft.net, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netfilter: fix dangling pointer access of fake_rtable
Date: Mon, 22 Apr 2019 11:35:02 +0200 [thread overview]
Message-ID: <20190422093502.36da6z3qf7zxpwny@breakpoint.cc> (raw)
In-Reply-To: <CAN1Lvyo1CVopsB7iV=e-dAN9JDFg-SmQ8g6H6RrgD7qACAd4hQ@mail.gmail.com>
Rundong Ge <rdong.ge@gmail.com> wrote:
> br_nf_pre_routing will call the NF_INET_PRE_ROUTING hooks, at this
> time both entry->state.in and entry->state.out are not bridge device.
>
> NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb,
> skb->dev, NULL,
> br_nf_pre_routing_finish);
skb->dev is munged in setup_prerouting() to be bridge or vlan device on
top of bridge.
That being said, I think we need this fix at least:
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -197,8 +197,15 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
.size = sizeof(*entry) + route_key_size,
};
+ if (skb_dst(skb)) {
+ skb_dst_force(skb);
+ if (!skb_dst(skb)) {
+ status = -EHOSTUNREACH;
+ goto err;
+ }
+ }
+
nf_queue_entry_get_refs(entry);
- skb_dst_force(skb);
switch (entry->state.pf) {
case AF_INET:
Then, why not add, in dev_cmp:
dst = skb_dst(skb);
if (dst && dst->dev->index == index ...
?
next prev parent reply other threads:[~2019-04-22 9:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 6:56 [PATCH] netfilter: fix dangling pointer access of fake_rtable Rundong Ge
2019-04-18 9:58 ` Rundong Ge
2019-04-22 8:33 ` Pablo Neira Ayuso
2019-04-22 9:16 ` Rundong Ge
2019-04-22 9:35 ` Florian Westphal [this message]
2019-04-22 9:51 ` Rundong Ge
2019-04-22 10:10 ` Rundong Ge
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=20190422093502.36da6z3qf7zxpwny@breakpoint.cc \
--to=fw@strlen.de \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=kadlec@blackhole.kfki.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=rdong.ge@gmail.com \
--cc=roopa@cumulusnetworks.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;
as well as URLs for NNTP newsgroup(s).