Skip to content

Commit 56f9b95

Browse files
Florian Westphalgregkh
authored andcommitted
bridge: drop netfilter fake rtable unconditionally
[ Upstream commit a13b2082ece95247779b9995c4e91b4246bed023 ] Andreas reports kernel oops during rmmod of the br_netfilter module. Hannes debugged the oops down to a NULL rt6info->rt6i_indev. Problem is that br_netfilter has the nasty concept of adding a fake rtable to skb->dst; this happens in a br_netfilter prerouting hook. A second hook (in bridge LOCAL_IN) is supposed to remove these again before the skb is handed up the stack. However, on module unload hooks get unregistered which means an skb could traverse the prerouting hook that attaches the fake_rtable, while the 'fake rtable remove' hook gets removed from the hooklist immediately after. Fixes: 34666d4 ("netfilter: bridge: move br_netfilter out of the core") Reported-by: Andreas Karis <akaris@redhat.com> Debugged-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: Florian Westphal <fw@strlen.de> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aed728c commit 56f9b95

2 files changed

Lines changed: 1 addition & 21 deletions

File tree

net/bridge/br_input.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ EXPORT_SYMBOL(br_should_route_hook);
2929
static int
3030
br_netif_receive_skb(struct net *net, struct sock *sk, struct sk_buff *skb)
3131
{
32+
br_drop_fake_rtable(skb);
3233
return netif_receive_skb(skb);
3334
}
3435

net/bridge/br_netfilter_hooks.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -516,21 +516,6 @@ static unsigned int br_nf_pre_routing(void *priv,
516516
}
517517

518518

519-
/* PF_BRIDGE/LOCAL_IN ************************************************/
520-
/* The packet is locally destined, which requires a real
521-
* dst_entry, so detach the fake one. On the way up, the
522-
* packet would pass through PRE_ROUTING again (which already
523-
* took place when the packet entered the bridge), but we
524-
* register an IPv4 PRE_ROUTING 'sabotage' hook that will
525-
* prevent this from happening. */
526-
static unsigned int br_nf_local_in(void *priv,
527-
struct sk_buff *skb,
528-
const struct nf_hook_state *state)
529-
{
530-
br_drop_fake_rtable(skb);
531-
return NF_ACCEPT;
532-
}
533-
534519
/* PF_BRIDGE/FORWARD *************************************************/
535520
static int br_nf_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
536521
{
@@ -900,12 +885,6 @@ static struct nf_hook_ops br_nf_ops[] __read_mostly = {
900885
.hooknum = NF_BR_PRE_ROUTING,
901886
.priority = NF_BR_PRI_BRNF,
902887
},
903-
{
904-
.hook = br_nf_local_in,
905-
.pf = NFPROTO_BRIDGE,
906-
.hooknum = NF_BR_LOCAL_IN,
907-
.priority = NF_BR_PRI_BRNF,
908-
},
909888
{
910889
.hook = br_nf_forward_ip,
911890
.pf = NFPROTO_BRIDGE,

0 commit comments

Comments
 (0)