From nobody Sat Jun 13 13:34:07 2026 Received: from buffalo.tulip.relay.mailchannels.net (buffalo.tulip.relay.mailchannels.net [23.83.218.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 831882DA762 for ; Thu, 7 May 2026 18:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.218.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778177562; cv=pass; b=XsBKVJAPAXgxclRMH/gjIijLWi5mQm/ypuUPwDLJbLsg4POd3IZRBcuL3C+dhnVPRbg+imudR2kVnwuzIv6BzBtn5wXAlhrecVA4Wqa+si66NWtpy4gVTFw7NPMzQ2K7d3yA7bT7YfoOFyk1Y0bQHvm3L4+pOAenXDc+idXQ+Rg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778177562; c=relaxed/simple; bh=ve82Z28KZk12vu5ebEgXyEIr0EdSCYNCTcG+bwQis7w=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fCPLQcUTWuvbcOPj9Pvs4D3jy0oL/VE7QRjRcD1ByX0Gkj63Ghos25PDpGtPBmgt7DqNx8VM+nSUXbDC1/nG9JckfcgdSMDfYzl5cVrxslIDZUnw+xywtLIrJ3qvoKQYRF5WbSlIW0B2nrvn6Px9bh9WoOnuNjUwNvPy5bCihKI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=fail smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=koFHpJEi; arc=pass smtp.client-ip=23.83.218.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="koFHpJEi" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 339384C2425; Thu, 07 May 2026 11:29:30 +0000 (UTC) Received: from pdx1-sub0-mail-a253.dreamhost.com (trex-green-1.trex.outbound.svc.cluster.local [100.98.15.35]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id A39CC4C245A; Thu, 07 May 2026 11:29:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; d=mailchannels.net; s=arc-2022; cv=none; t=1778153369; b=OGgC3Zsd9adLzWb/AjZqjhFAWi6DAPt6DmjqAK2AQmuval8ahhlZcWK67HBxBCHB/Rq+HI LTs0GrYH2+oDHV40fVd4FgxUok5MfaSbIvqEFC8ftLkbdRrXKB45sW9FNQu6kRCy32OlhV Qtpa7xYB7cRZuKqIj2FbsvoM7F6tw/pZErga76GeRc0KqhmeLlluTpQf5BQrO1750qRNWT 4jUrMUzYFMTiSt+idhEySJ1hWy4Vv26PmxXVzeRAmv+rwsoH9LVeBktt0oJ+Gj4AnimZTK Ja9R37z3cN31K891RmpAqHRPV0FZ/25bJ4+XirxZKGdrekZGdaa9o7N3WjlQyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1778153369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=isynBFy69Ep+qngn9fQCRuv9q80ee5G+y9kZHaCKpqk=; b=FAvppYtEBj4aNI3fcqBDF0fnc8Y+gz4b5PMsHtlJLGf0m4JqLj26bAyydSbyJzp/7e1JOo ZU4yzxiCS0psp4X9Dxbdq3Y37h2gz/MCodriF6kFd1F8TgkQipFHgWGeV1o8Jt8cSVP0Fe FIX3uKhIak7u2MGe6Z9t6UtIaf/aDQkoxZqw7qvz8C5CE9BKKskImBQJAMm9CR0/PP0rYC MG0fUgEysLOryWnoBnz0I9cAWIpLVJFu0I+qmu8lh10SC0wHer6KvZLscGEbANPG2vIIfW 67IMnzL3f0XfhLEMMcoWEkWModmFzxP4POKAZOWsMawZBowLiWlh3f8RYwowSw== ARC-Authentication-Results: i=1; rspamd-5c5444c55f-s82zq; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Plucky-Minister: 583d194a1c23d7d8_1778153370050_3567574740 X-MC-Loop-Signature: 1778153370050:249777459 X-MC-Ingress-Time: 1778153370050 Received: from pdx1-sub0-mail-a253.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.15.35 (trex/7.1.5); Thu, 07 May 2026 11:29:29 +0000 Received: from localhost.localdomain (cpe-188-129-77-158.dynamic.amis.hr [188.129.77.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a253.dreamhost.com (Postfix) with ESMTPSA id 4gB9533HfYzyq0; Thu, 7 May 2026 04:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1778153369; bh=isynBFy69Ep+qngn9fQCRuv9q80ee5G+y9kZHaCKpqk=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=koFHpJEi2KjUtIPBwZnm3zNvGGCb8oOikaVsx5iLDv2O83gmbJZrBA3TkoHswWwQS P8nuocPoAyj1bp0weA08NCv2zK9FKYV3NxuAJKITWz7qRyWdQ/tmilPQA/E5XIE46E rwQ3jF7AZQP2hTpRRsRRYOCj55RCj9Hf+ePs8ZU7n9rr28Iu2+Ln4HPiDY9yfaOhN6 RPBmD809+rZ9kp2GNkloE2B2IT8tYiMZSwK9E9DOpPzZ7F3vfUkJnQ44ZMW3GxI53j 0Iis3W+a4UJ1hy71IqPK5CCGHjKqNF7swelO8S7xPwZHNXjkKMy+9jQiB/JHdUX4ag PNabJLZLvooyA== From: Davidlohr Bueso To: tglx@kernel.org, peterz@infradead.org, mingo@redhat.com Cc: keenanat2000@gmail.com, dave@stgolabs.net, linux-kernel@vger.kernel.org, syzbot+78147abe6c524f183ee9@syzkaller.appspotmail.com Subject: [PATCH -tip] locking/rtmutex: Skip remove_waiter() when waiter is not enqueued Date: Thu, 7 May 2026 04:29:13 -0700 Message-Id: <20260507112913.1019537-1-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" syzbot triggered the following splat in remove_waiter() via FUTEX_CMP_REQUEUE_PI: KASAN: null-ptr-deref in range [0x0000000000000a88-0x0000000000000a8f] class_raw_spinlock_constructor remove_waiter+0x159/0x1200 kernel/locking/rtmutex.c:1561 rt_mutex_start_proxy_lock+0x103/0x120 futex_requeue+0x10e4/0x20d0 __x64_sys_futex+0x34f/0x4d0 task_blocks_on_rt_mutex() does not arm the waiter upon deadlock detection, leaving waiter->task nil, where 3bfdc63936dd ("rtmutex: Use waiter::task in= stead of current in remove_waiter()") made this fatal. Furthermore, rt_mutex_start_proxy_lock() should not be calling into remove_= waiter() upon a successfully grabbing the rtmutex. 1a1fb985f2e2 ("futex: Handle earl= y deadlock return correctly"), moved the remove_waiter() out of __rt_mutex_start_proxy= _lock() (where 'ret' was only ever 0 or < 0) into the wrapper. Tighten this check to account for try_to_take_rt_mutex(). Fixes: 3bfdc63936dd ("rtmutex: Use waiter::task instead of current in remov= e_waiter()") Link: https://lore.kernel.org/all/69f114ac.050a0220.ac8b.0003.GAE@google.co= m/ Reported-by: syzbot+78147abe6c524f183ee9@syzkaller.appspotmail.com Signed-off-by: Davidlohr Bueso --- kernel/locking/rtmutex.c | 3 +++ kernel/locking/rtmutex_api.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 4f386ea6c792..daeeeef973e2 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1558,6 +1558,9 @@ static void __sched remove_waiter(struct rt_mutex_bas= e *lock, =20 lockdep_assert_held(&lock->wait_lock); =20 + if (!waiter_task) /* never enqueued */ + return; + scoped_guard(raw_spinlock, &waiter_task->pi_lock) { rt_mutex_dequeue(lock, waiter); waiter_task->pi_blocked_on =3D NULL; diff --git a/kernel/locking/rtmutex_api.c b/kernel/locking/rtmutex_api.c index 124219aea46e..514fce7a4e0a 100644 --- a/kernel/locking/rtmutex_api.c +++ b/kernel/locking/rtmutex_api.c @@ -365,7 +365,7 @@ int __sched rt_mutex_start_proxy_lock(struct rt_mutex_b= ase *lock, =20 raw_spin_lock_irq(&lock->wait_lock); ret =3D __rt_mutex_start_proxy_lock(lock, waiter, task, &wake_q); - if (unlikely(ret)) + if (unlikely(ret < 0)) remove_waiter(lock, waiter); preempt_disable(); raw_spin_unlock_irq(&lock->wait_lock); --=20 2.39.5