From: "Luis Claudio R. Goncalves" <lgoncalv@redhat.com>
To: linux-rt-users <linux-rt-users@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
stable-rt@vger.kernel.org
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Chunyu Hu <chuhu@redhat.com>
Subject: [RFC RT v5.10] [rt] repair usage of raw_v6_hashinfo.lock in raw_seq_start()
Date: Mon, 4 Oct 2021 22:53:08 -0300 [thread overview]
Message-ID: <YVuwBEWw4F7NGUd2@uudg.org> (raw)
Avoid a possible circular locking dependency by taking the softirq_ctrl.lock
before taking raw_v6_hashinfo.lock in raw_seq_start(), keeping locking order
consistent.
Lockdep splat:
[ 254.623863] ======================================================
[ 254.623864] WARNING: possible circular locking dependency detected
[ 254.623865] 5.10.65-rt53+ #1 Tainted: G S W I
[ 254.623866] ------------------------------------------------------
[ 254.623866] read_all/3963 is trying to acquire lock:
[ 254.623867] ffffa05cde218220 ((softirq_ctrl.lock).lock){+.+.}-{2:2}, at: __local_bh_disable_ip+0x116/0x2f0
[ 254.623876]
but task is already holding lock:
[ 254.623877] ffffffffb68e93e0 (raw_v6_hashinfo.lock){++.+}-{0:0}, at: raw_seq_start+0x25/0x60
[ 254.623883]
which lock already depends on the new lock.
...
[ 254.623974] Possible unsafe locking scenario:
[ 254.623975] CPU0 CPU1
[ 254.623975] ---- ----
[ 254.623975] lock(raw_v6_hashinfo.lock);
[ 254.623976] lock((softirq_ctrl.lock).lock);
[ 254.623977] lock(raw_v6_hashinfo.lock);
[ 254.623978] lock((softirq_ctrl.lock).lock);
[ 254.623978]
*** DEADLOCK ***
[ 254.623979] 3 locks held by read_all/3963:
[ 254.623980] #0: ffffa055d0c35990 (&p->lock){+.+.}-{0:0}, at: seq_read_iter+0x56/0x420
[ 254.623983] #1: ffffffffb68e93e0 (raw_v6_hashinfo.lock){++.+}-{0:0}, at: raw_seq_start+0x25/0x60
[ 254.623986] #2: ffffffffb64c8fa0 (rcu_read_lock){....}-{1:2}, at: rt_read_lock+0x7d/0x1e0
Reported-by: Chunyu Hu <chuhu@redhat.com>
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
---
net/ipv4/raw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index a0188eb2689f..584d08679e3a 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -1051,7 +1051,7 @@ void *raw_seq_start(struct seq_file *seq, loff_t *pos)
{
struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file));
- read_lock(&h->lock);
+ read_lock_bh(&h->lock);
return *pos ? raw_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
}
EXPORT_SYMBOL_GPL(raw_seq_start);
@@ -1073,7 +1073,7 @@ void raw_seq_stop(struct seq_file *seq, void *v)
{
struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file));
- read_unlock(&h->lock);
+ read_unlock_bh(&h->lock);
}
EXPORT_SYMBOL_GPL(raw_seq_stop);
next reply other threads:[~2021-10-05 1:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-05 1:53 Luis Claudio R. Goncalves [this message]
2021-10-11 16:33 ` [RFC RT v5.10] [rt] repair usage of raw_v6_hashinfo.lock in raw_seq_start() Sebastian Andrzej Siewior
2021-10-18 15:51 ` Luis Goncalves
2021-10-27 9:06 ` Sebastian Andrzej Siewior
2021-11-04 18:48 ` Luis Goncalves
2021-11-05 17:18 ` Sebastian Andrzej Siewior
2021-11-05 17:31 ` Sebastian Andrzej Siewior
2021-11-04 18:55 ` Luis Goncalves
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=YVuwBEWw4F7NGUd2@uudg.org \
--to=lgoncalv@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=chuhu@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=stable-rt@vger.kernel.org \
/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