Skip to content

Commit

Permalink
netfilter: bridge: don't leak skb in error paths
Browse files Browse the repository at this point in the history
br_nf_dev_queue_xmit must free skb in its error path.
NF_DROP is misleading -- its an okfn, not a netfilter hook.

Fixes: 462fb2a ("bridge : Sanitize skb before it enters the IP stack")
Fixes: efb6de9 ("netfilter: bridge: forward IPv6 fragmented packets")
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Florian Westphal authored and ummakynes committed Jul 2, 2015
1 parent 3bd2299 commit dd302b5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/bridge/br_netfilter_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,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;

Expand All @@ -769,7 +769,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;

Expand All @@ -784,12 +784,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 ********************************************/
Expand Down

0 comments on commit dd302b5

Please sign in to comment.