diff options
author | Florian Westphal <fw@strlen.de> | 2015-04-20 06:35:47 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-04-24 14:51:40 -0400 |
commit | 547c4b547e07dcc60874b6ef6252dd49ff74aec1 (patch) | |
tree | 942709ba5115ae7840efc3d71b6093de4b39e575 /include | |
parent | 4c4ed0748f82e26d8b884383e6737cf5a861ed6f (diff) |
netfilter: bridge: fix NULL deref in physin/out ifindex helpers
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: c737b7c4510026 ("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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netfilter_bridge.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h index ab8f76dba668..f2fdb5a52070 100644 --- a/include/linux/netfilter_bridge.h +++ b/include/linux/netfilter_bridge.h | |||
@@ -39,12 +39,24 @@ static inline void br_drop_fake_rtable(struct sk_buff *skb) | |||
39 | 39 | ||
40 | static inline int nf_bridge_get_physinif(const struct sk_buff *skb) | 40 | static inline int nf_bridge_get_physinif(const struct sk_buff *skb) |
41 | { | 41 | { |
42 | return skb->nf_bridge ? skb->nf_bridge->physindev->ifindex : 0; | 42 | struct nf_bridge_info *nf_bridge; |
43 | |||
44 | if (skb->nf_bridge == NULL) | ||
45 | return 0; | ||
46 | |||
47 | nf_bridge = skb->nf_bridge; | ||
48 | return nf_bridge->physindev ? nf_bridge->physindev->ifindex : 0; | ||
43 | } | 49 | } |
44 | 50 | ||
45 | static inline int nf_bridge_get_physoutif(const struct sk_buff *skb) | 51 | static inline int nf_bridge_get_physoutif(const struct sk_buff *skb) |
46 | { | 52 | { |
47 | return skb->nf_bridge ? skb->nf_bridge->physoutdev->ifindex : 0; | 53 | struct nf_bridge_info *nf_bridge; |
54 | |||
55 | if (skb->nf_bridge == NULL) | ||
56 | return 0; | ||
57 | |||
58 | nf_bridge = skb->nf_bridge; | ||
59 | return nf_bridge->physoutdev ? nf_bridge->physoutdev->ifindex : 0; | ||
48 | } | 60 | } |
49 | 61 | ||
50 | static inline struct net_device * | 62 | static inline struct net_device * |