diff options
author | Taehee Yoo <ap420073@gmail.com> | 2020-03-13 09:50:14 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-03-16 11:46:09 +0300 |
commit | 173756b86803655d70af7732079b3aa935e6ab68 (patch) | |
tree | 3a2c08f723db982de612dd00162f0a6e3f1b5681 /net/hsr/hsr_framereg.c | |
parent | dcadaec2245616aedd94ff0129db2b13f2d8deb8 (diff) | |
download | linux-173756b86803655d70af7732079b3aa935e6ab68.tar.xz |
hsr: use rcu_read_lock() in hsr_get_node_{list/status}()
hsr_get_node_{list/status}() are not under rtnl_lock() because
they are callback functions of generic netlink.
But they use __dev_get_by_index() without rtnl_lock().
So, it would use unsafe data.
In order to fix it, rcu_read_lock() and dev_get_by_index_rcu()
are used instead of __dev_get_by_index().
Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/hsr/hsr_framereg.c')
-rw-r--r-- | net/hsr/hsr_framereg.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index 3ba7f61be107..a64bb64935a6 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -482,12 +482,9 @@ int hsr_get_node_data(struct hsr_priv *hsr, struct hsr_port *port; unsigned long tdiff; - rcu_read_lock(); node = find_node_by_addr_A(&hsr->node_db, addr); - if (!node) { - rcu_read_unlock(); - return -ENOENT; /* No such entry */ - } + if (!node) + return -ENOENT; ether_addr_copy(addr_b, node->macaddress_B); @@ -522,7 +519,5 @@ int hsr_get_node_data(struct hsr_priv *hsr, *addr_b_ifindex = -1; } - rcu_read_unlock(); - return 0; } |