]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
bridge: vlan: Prevent possible use-after-free
authorIdo Schimmel <idosch@mellanox.com>
Fri, 30 Oct 2015 16:46:19 +0000 (17:46 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Nov 2015 20:40:10 +0000 (15:40 -0500)
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.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_vlan.c

index 5f0d0cc4744f2219f2fd77a1a3cd11b266f03748..1054696323d730528abe2ee138743553dccf5cf7 100644 (file)
@@ -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);