aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>2014-04-09 04:00:30 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-11 15:12:47 -0400
commiteb7076182d1ae4bc4641534134ed707100d76acc (patch)
treea4beecd9fe24c72173ecfa9adf7d125a8dd19ef0 /net
parentdb29868653394937037d71dc3545768302dda643 (diff)
bridge: Fix double free and memory leak around br_allowed_ingress
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: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/bridge/br_input.c2
-rw-r--r--net/bridge/br_vlan.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index d0cca3c65f01..7985deaff52f 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -73,7 +73,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
73 goto drop; 73 goto drop;
74 74
75 if (!br_allowed_ingress(p->br, nbp_get_vlan_info(p), skb, &vid)) 75 if (!br_allowed_ingress(p->br, nbp_get_vlan_info(p), skb, &vid))
76 goto drop; 76 goto out;
77 77
78 /* insert into forwarding database after filtering to avoid spoofing */ 78 /* insert into forwarding database after filtering to avoid spoofing */
79 br = p->br; 79 br = p->br;
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 91510712c7a7..4a3716102789 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -170,7 +170,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
170 * rejected. 170 * rejected.
171 */ 171 */
172 if (!v) 172 if (!v)
173 return false; 173 goto drop;
174 174
175 /* If vlan tx offload is disabled on bridge device and frame was 175 /* If vlan tx offload is disabled on bridge device and frame was
176 * sent from vlan device on the bridge device, it does not have 176 * sent from vlan device on the bridge device, it does not have
@@ -193,7 +193,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
193 * vlan untagged or priority-tagged traffic belongs to. 193 * vlan untagged or priority-tagged traffic belongs to.
194 */ 194 */
195 if (pvid == VLAN_N_VID) 195 if (pvid == VLAN_N_VID)
196 return false; 196 goto drop;
197 197
198 /* PVID is set on this port. Any untagged or priority-tagged 198 /* PVID is set on this port. Any untagged or priority-tagged
199 * ingress frame is considered to belong to this vlan. 199 * ingress frame is considered to belong to this vlan.
@@ -216,7 +216,8 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
216 /* Frame had a valid vlan tag. See if vlan is allowed */ 216 /* Frame had a valid vlan tag. See if vlan is allowed */
217 if (test_bit(*vid, v->vlan_bitmap)) 217 if (test_bit(*vid, v->vlan_bitmap))
218 return true; 218 return true;
219 219drop:
220 kfree_skb(skb);
220 return false; 221 return false;
221} 222}
222 223