Skip to contentSkip to conversation

bridge: vlan: failure path and comment fixes

PATCH In review Nikolay Aleksandrov 2 participants 4 messages Oct 30, 2015 – Nov 2, 2015

Subsystems (3)
lore
Share & tools
lore

Nikolay Aleksandrov

author maintainer
#0 lore raw

cover bridge: vlan: failure path and comment fixes

From: Nikolay Aleksandrov <[email protected]>

Hi,
This is a set from Ido which takes care of one failure path error in nbp_vlan_init (patch 1) and a few comment errors (patch 2). I must admit I didn't expect the port init continues after a vlan init failure but should've checked to make sure. Thanks to Ido for catching these!

Cheers,
Nik

Ido Schimmel (2):
bridge: vlan: Prevent possible use-after-free
bridge: vlan: Use correct flag name in comment

 net/bridge/br_vlan.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.4.3
author maintainer
#1 lore raw

PATCH 1/2 bridge: vlan: Prevent possible use-after-free

From: Ido Schimmel <[email protected]>

When adding a port to a bridge we initialize VLAN filtering on it. We do not bail out in case an error occurred in nbp_vlan_init, as it can be used as a non VLAN filtering bridge.

However, if VLAN filtering is required and an error occurred in nbp_vlan_init, we should set vlgrp to NULL, so that VLAN filtering functions (e.g. br_vlan_find, br_get_pvid) will know the struct is invalid and will not try to access it.

---
 net/bridge/br_vlan.c | 2 ++
 1 file changed, 2 insertions(+)
net/bridge/br_vlan.c +2 -0
index 5f0d0cc4744f..1054696323d7 100644
@@ -914,6 +914,8 @@ out:
 	return ret;
 
 err_vlan_add:
+	RCU_INIT_POINTER(p->vlgrp, NULL);
+	synchronize_rcu();
 	rhashtable_destroy(&vg->vlan_hash);
 err_rhtbl:
 	kfree(vg);
Signature · 1 line
2.4.3
author maintainer
#2 lore raw

PATCH 2/2 bridge: vlan: Use correct flag name in comment

In reply to Nikolay Aleksandrov

From: Ido Schimmel <[email protected]>

The flag used to indicate if a VLAN should be used for filtering - as opposed to context only - on the bridge itself (e.g. br0) is called 'brentry' and not 'brvlan'.

---
 net/bridge/br_vlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_vlan.c +3 -3
index 1054696323d7..dc1a2da55d09 100644
@@ -180,11 +180,11 @@ static void br_vlan_put_master(struct net_bridge_vlan *masterv)
  * devices. There are four possible calls to this function in terms of the
  * vlan entry type:
  * 1. vlan is being added on a port (no master flags, global entry exists)
- * 2. vlan is being added on a bridge (both master and brvlan flags)
+ * 2. vlan is being added on a bridge (both master and brentry flags)
  * 3. vlan is being added on a port, but a global entry didn't exist which
- *    is being created right now (master flag set, brvlan flag unset), the
+ *    is being created right now (master flag set, brentry flag unset), the
  *    global entry is used for global per-vlan features, but not for filtering
- * 4. same as 3 but with both master and brvlan flags set so the entry
+ * 4. same as 3 but with both master and brentry flags set so the entry
  *    will be used for filtering in both the port and the bridge
  */
 static int __vlan_add(struct net_bridge_vlan *v, u16 flags)
Signature · 1 line
2.4.3
maintainer
#3 lore raw
In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>
Date: Fri, 30 Oct 2015 17:46:18 +0100

Quoted 5 lines

This is a set from Ido which takes care of one failure path error in nbp_vlan_init (patch 1) and a few comment errors (patch 2). I must admit I didn't expect the port init continues after a vlan init failure but should've checked to make sure. Thanks to Ido for catching these!

Series applied, thanks.