Commit 479a9bef authored by Toshiaki Makita's avatar Toshiaki Makita Committed by Kamal Mostafa

bridge: Fix double free and memory leak around br_allowed_ingress

[ Upstream commit eb707618 ]

br_allowed_ingress() has two problems.

1. If br_allowed_ingress() is called by br_handle_frame_finish() and
vlan_untag() in br_allowed_ingress() fails, skb will be freed by both
vlan_untag() and br_handle_frame_finish().

2. If br_allowed_ingress() is called by br_dev_xmit() and
br_allowed_ingress() fails, the skb will not be freed.

Fix these two problems by freeing the skb in br_allowed_ingress()
if it fails.
Signed-off-by: default avatarToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent a9a595ce
...@@ -72,7 +72,7 @@ int br_handle_frame_finish(struct sk_buff *skb) ...@@ -72,7 +72,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
goto drop; goto drop;
if (!br_allowed_ingress(p->br, nbp_get_vlan_info(p), skb, &vid)) if (!br_allowed_ingress(p->br, nbp_get_vlan_info(p), skb, &vid))
goto drop; goto out;
/* insert into forwarding database after filtering to avoid spoofing */ /* insert into forwarding database after filtering to avoid spoofing */
br = p->br; br = p->br;
......
...@@ -193,7 +193,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, ...@@ -193,7 +193,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
* rejected. * rejected.
*/ */
if (!v) if (!v)
return false; goto drop;
err = br_vlan_get_tag(skb, vid); err = br_vlan_get_tag(skb, vid);
if (!*vid) { if (!*vid) {
...@@ -204,7 +204,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, ...@@ -204,7 +204,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
* vlan untagged or priority-tagged traffic belongs to. * vlan untagged or priority-tagged traffic belongs to.
*/ */
if (pvid == VLAN_N_VID) if (pvid == VLAN_N_VID)
return false; goto drop;
/* PVID is set on this port. Any untagged or priority-tagged /* PVID is set on this port. Any untagged or priority-tagged
* ingress frame is considered to belong to this vlan. * ingress frame is considered to belong to this vlan.
...@@ -227,7 +227,8 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, ...@@ -227,7 +227,8 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
/* Frame had a valid vlan tag. See if vlan is allowed */ /* Frame had a valid vlan tag. See if vlan is allowed */
if (test_bit(*vid, v->vlan_bitmap)) if (test_bit(*vid, v->vlan_bitmap))
return true; return true;
drop:
kfree_skb(skb);
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment