Skip to contentSkip to conversation

net: bridge: vlan: fix memory leak in __allowed_ingress

PATCH Applied Tim Yi 3 participants 3 messages Jan 27, 2022

Subsystems (3)
lore
Share & tools
lore

Tim Yi

author
#0 lore raw

PATCH 1/1 net: bridge: vlan: fix memory leak in __allowed_ingress

When using per-vlan state, if vlan snooping and stats are disabled, untagged or priority-tagged ingress frame will go to check pvid state. If the port state is forwarding and the pvid state is not learning/forwarding, untagged or priority-tagged frame will be dropped but skb memory is not freed.
Should free skb when __allowed_ingress returns false.

---
 net/bridge/br_vlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_vlan.c +3 -3
index 84ba456a78cc..88c4297cddee 100644
@@ -560,10 +560,10 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		    !br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) {
 			if (*state == BR_STATE_FORWARDING) {
 				*state = br_vlan_get_pvid_state(vg);
-				return br_vlan_state_allowed(*state, true);
-			} else {
-				return true;
+				if (!br_vlan_state_allowed(*state, true))
+					goto drop;
 			}
+			return true;
 		}
 	}
 	v = br_vlan_find(vg, *vid);
Signature · 1 line
2.28.0.618.g9bc233ae1c
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Tim Yi

When using per-vlan state, if vlan snooping and stats are disabled, untagged or priority-tagged ingress frame will go to check pvid state. If the port state is forwarding and the pvid state is not learning/forwarding, untagged or priority-tagged frame will be dropped but skb memory is not freed.
Should free skb when __allowed_ingress returns false.

---
 net/bridge/br_vlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_vlan.c +0 -0
index 84ba456a78cc..88c4297cddee 100644
@@ -560,10 +560,10 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		    !br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) {
 			if (*state == BR_STATE_FORWARDING) {
 				*state = br_vlan_get_pvid_state(vg);

net/bridge/br_vlan.c static bool __allowed_ingress(const struct net_bridge *br, · line 569

Quoted 10 lines
net/bridge/br_vlan.c +3 -3
-				return br_vlan_state_allowed(*state, true);
-			} else {
-				return true;
+				if (!br_vlan_state_allowed(*state, true))
+					goto drop;
 			}
+			return true;
 		}
 	}
 	v = br_vlan_find(vg, *vid);

Good catch, also should go to stable, here's the appropriate fixes tag.

Fixes a580c76d534c ("net: bridge: vlan: add per-vlan state")

Thanks,
Nik

#2 lore raw
In reply to Tim Yi
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 27 Jan 2022 15:49:53 +0800 you wrote:

When using per-vlan state, if vlan snooping and stats are disabled, untagged or priority-tagged ingress frame will go to check pvid state. If the port state is forwarding and the pvid state is not learning/forwarding, untagged or priority-tagged frame will be dropped but skb memory is not freed.
Should free skb when __allowed_ingress returns false.

[...]

Here is the summary with links:
- net: bridge: vlan: fix memory leak in __allowed_ingress

    https://git.kernel.org/netdev/net/c/fd20d9738395

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html