From: Andrei Vagin <avagin@google.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Boqun Feng <boqun@kernel.org>, Waiman Long <longman@redhat.com>,
linux-kernel@vger.kernel.org, Andrei Vagin <avagin@google.com>,
syzbot+3d2ff92c67127d337463@syzkaller.appspotmail.com
Subject: [PATCH] locking/rwsem: Fix logic error in rwsem_del_waiter()
Date: Sat, 14 Mar 2026 18:26:07 +0000 [thread overview]
Message-ID: <20260314182607.3343346-1-avagin@google.com> (raw)
Commit 1ea4b473504b ("locking/rwsem: Remove the list_head from struct
rw_semaphore") introduced a logic error in rwsem_del_waiter().
The root cause of this issue is an inconsistency in the return values of
__rwsem_del_waiter() and rwsem_del_waiter(). Specifically,
__rwsem_del_waiter() returns true when the wait list becomes empty,
whereas rwsem_del_waiter() is supposed to return true if the wait list
is NOT empty.
This caused a null pointer dereference in rwsem_mark_wake() because it
was being called when sem->first_waiter was NULL.
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: syzbot+3d2ff92c67127d337463@syzkaller.appspotmail.com
Tested-by: syzbot+3d2ff92c67127d337463@syzkaller.appspotmail.com
Fixes: 1ea4b473504b ("locking/rwsem: Remove the list_head from struct rw_semaphore")
Signed-off-by: Andrei Vagin <avagin@google.com>
---
kernel/locking/rwsem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index ba4cb74de064..bf647097369c 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -370,7 +370,7 @@ bool __rwsem_del_waiter(struct rw_semaphore *sem, struct rwsem_waiter *waiter)
{
if (list_empty(&waiter->list)) {
sem->first_waiter = NULL;
- return true;
+ return false;
}
if (sem->first_waiter == waiter) {
@@ -379,7 +379,7 @@ bool __rwsem_del_waiter(struct rw_semaphore *sem, struct rwsem_waiter *waiter)
}
list_del(&waiter->list);
- return false;
+ return true;
}
/*
--
2.53.0.851.ga537e3e6e9-goog
next reply other threads:[~2026-03-14 18:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 18:26 Andrei Vagin [this message]
2026-03-16 11:51 ` [PATCH] locking/rwsem: Fix logic error in rwsem_del_waiter() Peter Zijlstra
[not found] ` <025cdbad-99e1-4342-9f37-2564c555a8d1@redhat.com>
2026-03-16 17:49 ` Waiman Long
2026-03-16 19:04 ` Waiman Long
2026-03-17 21:23 ` Andrei Vagin
2026-03-17 23:39 ` Waiman Long
2026-03-18 8:02 ` [tip: locking/core] " tip-bot2 for Andrei Vagin
2026-03-18 16:49 ` Andrei Vagin
2026-03-18 17:15 ` Waiman Long
2026-03-18 20:31 ` Peter Zijlstra
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=20260314182607.3343346-1-avagin@google.com \
--to=avagin@google.com \
--cc=boqun@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=syzbot+3d2ff92c67127d337463@syzkaller.appspotmail.com \
--cc=will@kernel.org \
--cc=willy@infradead.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