diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2020-09-22 01:07:09 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-09-21 17:37:44 -0700 |
commit | 99f62a746066fa436aa15d4606a538569540db08 (patch) | |
tree | b7fdc47fff971eaa6b97174ee47df797f24fdc2e /net/ipv4/inet_diag.c | |
parent | 47cec3f68c6ca33fdfe381934c6c581cd716df96 (diff) | |
download | linux-99f62a746066fa436aa15d4606a538569540db08.tar.gz linux-99f62a746066fa436aa15d4606a538569540db08.tar.bz2 linux-99f62a746066fa436aa15d4606a538569540db08.zip |
net: bridge: br_vlan_get_pvid_rcu() should dereference the VLAN group under RCU
When calling the RCU brother of br_vlan_get_pvid(), lockdep warns:
=============================
WARNING: suspicious RCU usage
5.9.0-rc3-01631-g13c17acb8e38-dirty #814 Not tainted
-----------------------------
net/bridge/br_private.h:1054 suspicious rcu_dereference_protected() usage!
Call trace:
lockdep_rcu_suspicious+0xd4/0xf8
__br_vlan_get_pvid+0xc0/0x100
br_vlan_get_pvid_rcu+0x78/0x108
The warning is because br_vlan_get_pvid_rcu() calls nbp_vlan_group()
which calls rtnl_dereference() instead of rcu_dereference(). In turn,
rtnl_dereference() calls rcu_dereference_protected() which assumes
operation under an RCU write-side critical section, which obviously is
not the case here. So, when the incorrect primitive is used to access
the RCU-protected VLAN group pointer, READ_ONCE() is not used, which may
cause various unexpected problems.
I'm sad to say that br_vlan_get_pvid() and br_vlan_get_pvid_rcu() cannot
share the same implementation. So fix the bug by splitting the 2
functions, and making br_vlan_get_pvid_rcu() retrieve the VLAN groups
under proper locking annotations.
Fixes: 7582f5b70f9a ("bridge: add br_vlan_get_pvid_rcu()")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_diag.c')
0 files changed, 0 insertions, 0 deletions