From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bonobo.aspen.relay.mailchannels.net (bonobo.aspen.relay.mailchannels.net [23.83.221.22]) (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 5E34D2F7EF2 for ; Wed, 3 Jun 2026 14:13:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=23.83.221.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496003; cv=none; b=TqvLDGm2yoVPB3BfZoK5B3MmBRZXm2/NUtTB6wpHrsVTbSsjss+0o2/8ajLE6awCAX+qJzzpbpIzbZsb/vfAS8yXFaYQY/1vsqxp9G6X+ooITJAut7Uik9a9i9aWmELBNHRof4rerpjATQSClk0wJpKPD14j010XGHvWYk5dd6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496003; c=relaxed/simple; bh=/Ey3lTvPvvm4mAolQAI5SF9ByxaCU42MJr4GOfSt1GA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LWJmbKGIJlAJ3EOH3Mkd1ohPttpmTy9t+3e6cyifYz/ICMptUstS8tHIehiGjAmkGzbjkyC5uqnMjRDo87g4ZKy0S4UzYqtDz3lSTm0imyRR9hNGaiMs2hivYZCSX48Sp9IkLUIp8KqjvH0+Wrpdxyqd75cIMBH5SO4XeKiVXM0= ARC-Authentication-Results:i=1; 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=oWfutwB0; arc=none smtp.client-ip=23.83.221.22 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="oWfutwB0" 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 9F160721D2B; Wed, 03 Jun 2026 14:04:06 +0000 (UTC) Received: from pdx1-sub0-mail-a256.dreamhost.com (trex-green-2.trex.outbound.svc.cluster.local [100.109.200.72]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 1C0DA720AB3; Wed, 03 Jun 2026 14:04:04 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Tasty-Cellar: 50c2cf68278922e2_1780495446331_1266574636 X-MC-Loop-Signature: 1780495446331:3686976126 X-MC-Ingress-Time: 1780495446331 Received: from pdx1-sub0-mail-a256.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.200.72 (trex/7.1.5); Wed, 03 Jun 2026 14:04:06 +0000 Received: from offworld (unknown [172.56.179.190]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a256.dreamhost.com (Postfix) with ESMTPSA id 4gVqDx38kKz105s; Wed, 3 Jun 2026 07:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1780495443; bh=yEaHODRS78TVVBek+NPSgAk9V742dPAkQs5eRNp08wE=; h=Date:From:To:Cc:Subject:Content-Type; b=oWfutwB0gFiXf06kf+KEibRuF6Wg51Wkig3b8SGqPdeJb0ZkjneqTNYRXmGbI5e5J yjyidQ1MjT+3hB6n9qTEOogiPbjck48BlfYl3df4HNev4EMe7fgY4maOBdxQDmS/6h NBNfYagwE9CRZ2sIJUnNrZpEPdY0aCyjR5Hsqp0Bhuwf12B4u0hrsj4W/b/NHJEupl pgqeEsmfUxv489JJ/Yo5vMzo3KgCsR7xgC5LiRe5EfnvxWgzd/d7B2xSR6MnXd7aVw HPMgtaujeatNtKO4h+W0wcew2xKwt8uaRhmwiekmOXCD3pQj/2by61rwoBAn8lPOp3 HAKbLgdpLBHyQ== Date: Wed, 3 Jun 2026 07:03:54 -0700 From: Davidlohr Bueso To: tglx@kernel.org, peterz@infradead.org, mingo@redhat.com Cc: keenanat2000@gmail.com, linux-kernel@vger.kernel.org, syzbot+78147abe6c524f183ee9@syzkaller.appspotmail.com Subject: Re: [PATCH -tip] locking/rtmutex: Skip remove_waiter() when waiter is not enqueued Message-ID: <20260603140354.pluitgpliv6fl6fi@offworld> References: <20260507112913.1019537-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20260507112913.1019537-1-dave@stgolabs.net> User-Agent: NeoMutt/20220429 ping On Thu, 07 May 2026, Davidlohr Bueso wrote: >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 instead >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 early 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 remove_waiter()") >Link: https://lore.kernel.org/all/69f114ac.050a0220.ac8b.0003.GAE@google.com/ >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_base *lock, > > lockdep_assert_held(&lock->wait_lock); > >+ if (!waiter_task) /* never enqueued */ >+ return; >+ > scoped_guard(raw_spinlock, &waiter_task->pi_lock) { > rt_mutex_dequeue(lock, waiter); > waiter_task->pi_blocked_on = 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_base *lock, > > raw_spin_lock_irq(&lock->wait_lock); > ret = __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); >-- >2.39.5 >