From: Juhee Kang <claudiajkang@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
eric.dumazet@gmail.com
Cc: ennoerlangen@gmail.com, george.mccollister@gmail.com,
olteanv@gmail.com, marco.wenzel@a-eberle.de,
xiong.zhenwu@zte.com.cn,
syzbot+f0eb4f3876de066b128c@syzkaller.appspotmail.com
Subject: [PATCH net] net: hsr: fix suspicious usage in hsr_node_get_first
Date: Thu, 10 Feb 2022 15:49:12 +0000 [thread overview]
Message-ID: <20220210154912.5803-1-claudiajkang@gmail.com> (raw)
Currently, to dereference hlist_node which is result of hlist_first_rcu(),
rcu_dereference() is used. But, suspicious RCU warnings occur because
the caller doesn't acquire RCU. So it was solved by adding rcu_read_lock().
The kernel test robot reports:
[ 53.750001][ T3597] =============================
[ 53.754849][ T3597] WARNING: suspicious RCU usage
[ 53.759833][ T3597] 5.17.0-rc2-syzkaller-00903-g45230829827b #0 Not tainted
[ 53.766947][ T3597] -----------------------------
[ 53.771840][ T3597] net/hsr/hsr_framereg.c:34 suspicious rcu_dereference_check() usage!
[ 53.780129][ T3597] other info that might help us debug this:
[ 53.790594][ T3597] rcu_scheduler_active = 2, debug_locks = 1
[ 53.798896][ T3597] 2 locks held by syz-executor.0/3597:
Fixes: 4acc45db7115 ("net: hsr: use hlist_head instead of list_head for mac addresses")
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Reported-by: syzbot+f0eb4f3876de066b128c@syzkaller.appspotmail.com
Signed-off-by: Juhee Kang <claudiajkang@gmail.com>
---
net/hsr/hsr_framereg.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index b3c6ffa1894d..92abdf855327 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -31,7 +31,10 @@ struct hsr_node *hsr_node_get_first(struct hlist_head *head)
{
struct hlist_node *first;
+ rcu_read_lock();
first = rcu_dereference(hlist_first_rcu(head));
+ rcu_read_unlock();
+
if (first)
return hlist_entry(first, struct hsr_node, mac_list);
--
2.25.1
next reply other threads:[~2022-02-10 15:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 15:49 Juhee Kang [this message]
2022-02-10 16:11 ` [PATCH net] net: hsr: fix suspicious usage in hsr_node_get_first Juhee Kang
2022-02-10 16:12 ` Vladimir Oltean
2022-02-10 17:03 ` Juhee Kang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220210154912.5803-1-claudiajkang@gmail.com \
--to=claudiajkang@gmail.com \
--cc=davem@davemloft.net \
--cc=ennoerlangen@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=kuba@kernel.org \
--cc=marco.wenzel@a-eberle.de \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=syzbot+f0eb4f3876de066b128c@syzkaller.appspotmail.com \
--cc=xiong.zhenwu@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox