Skip to content

Commit

Permalink
netfilter: bridge: fix NULL deref in physin/out ifindex helpers
Browse files Browse the repository at this point in the history
Might not have an outdev yet. We'll oops when iface goes down while skbs
are still nfqueue'd:

RIP: 0010:[<ffffffff81422a2f>]  [<ffffffff81422a2f>] dev_cmp+0x4f/0x80
nfqnl_rcv_dev_event+0xe2/0x150
notifier_call_chain+0x53/0xa0

Fixes: c737b7c ("netfilter: bridge: add helpers for fetching physin/outdev")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Apr 24, 2015
1 parent 4c4ed07 commit 547c4b5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions include/linux/netfilter_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,24 @@ static inline void br_drop_fake_rtable(struct sk_buff *skb)

static inline int nf_bridge_get_physinif(const struct sk_buff *skb)
{
return skb->nf_bridge ? skb->nf_bridge->physindev->ifindex : 0;
struct nf_bridge_info *nf_bridge;

if (skb->nf_bridge == NULL)
return 0;

nf_bridge = skb->nf_bridge;
return nf_bridge->physindev ? nf_bridge->physindev->ifindex : 0;
}

static inline int nf_bridge_get_physoutif(const struct sk_buff *skb)
{
return skb->nf_bridge ? skb->nf_bridge->physoutdev->ifindex : 0;
struct nf_bridge_info *nf_bridge;

if (skb->nf_bridge == NULL)
return 0;

nf_bridge = skb->nf_bridge;
return nf_bridge->physoutdev ? nf_bridge->physoutdev->ifindex : 0;
}

static inline struct net_device *
Expand Down

0 comments on commit 547c4b5

Please sign in to comment.