Use READ/WRITE_ONCE to annotate lockless pvid use, br_get_pvid() is the helper that should be used outside of the bridge vlan code. The rest of the vlan places that access pvid directly all have rtnl.
Signed-off-by: Nikolay Aleksandrov <[email protected]> --- net/bridge/br_private.h | 2 +- net/bridge/br_vlan.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 5b2c22ad669e..0efd2e79e255 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1687,7 +1687,7 @@ static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg) if (!vg) return 0; - return vg->pvid; + return READ_ONCE(vg->pvid); } static inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid) diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 2ae6ffb23399..a53054fcc093 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -41,7 +41,7 @@ static void __vlan_add_pvid(struct net_bridge_vlan_group *vg, return; br_vlan_set_pvid_state(vg, v->state); - vg->pvid = v->vid; + WRITE_ONCE(vg->pvid, v->vid); } static void __vlan_delete_pvid(struct net_bridge_vlan_group *vg, u16 vid) @@ -49,7 +49,7 @@ static void __vlan_delete_pvid(struct net_bridge_vlan_group *vg, u16 vid) if (vg->pvid != vid) return; - vg->pvid = 0; + WRITE_ONCE(vg->pvid, 0); } /* Update the BRIDGE_VLAN_INFO_PVID and BRIDGE_VLAN_INFO_UNTAGGED flags of @v. -- 2.47.3
