From: Peter Zijlstra <peterz@infradead.org>
To: Henry Wu <triangletrap12@gmail.com>
Cc: linux-kernel@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: Possible race in rt_mutex_adjust_prio_chain
Date: Thu, 6 Jul 2023 14:01:03 +0200 [thread overview]
Message-ID: <20230706120103.GJ2833176@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAG-UpRQsdL_Fs9HSEv2pDYXehJC+YXcYjiZKFLvkGBTZkkaTcg@mail.gmail.com>
On Thu, Jul 06, 2023 at 02:08:20PM +0800, Henry Wu wrote:
> Hi,
>
> I found that it's not safe to change waiter->prio after waiter
> dequeued from mutex's waiter rbtree because it's still on owner's
> pi_waiters rbtree. From my analysis, waiters on pi_waiters rbtree
> should be protected by pi_lock of task which have pi_waiters and
> corresponding rt_mutex's wait_lock, but pi_waiters is shared by many
> locks owned by this task, so actually we serialize changes on
> pi_waiters only by pi_lock.
>
> `rt_mutex_adjust_prio_chain' changes key of nodes of pi_waiters rbtree
> without pi_lock and pi_waiters rbtree's invariant is violated. Maybe
> we are enqueuing waiter on other cpu and pi_waiters rbtree will be
> corrupted.
Are you talking about [7];
Where we do waiter_update_prio() while only
holding [L] rtmutex->wait_lock.
VS
rt_mutex_adjust_prio() / task_top_pi_waiter() that accesses ->pi_waiters
while holding [P] task->pi_lock.
?
I'll go stare at that in more detail -- but I wanted to verify that's
what you're talking about.
> I attach a source file which can trigger this violation. I tested it
> on Ubuntu 20.04 LTS with 5.4 kernel.
Well, that's a horribly old kernel :-( Please double check on v6.4 and
consult that code for the discussion above -- I'm really not too
interested in debugging something ancient.
next prev parent reply other threads:[~2023-07-06 12:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 6:08 Henry Wu
2023-07-06 12:01 ` Peter Zijlstra [this message]
2023-07-06 19:58 ` Peter Zijlstra
2023-07-07 2:27 ` Henry Wu
[not found] ` <CAG-UpRTQ-ovVO02HRd5z-9oZGCPvZ0vODJse8oyuA9L-3NV_pQ@mail.gmail.com>
2023-07-07 2:09 ` Fwd: " Henry Wu
2023-07-07 12:59 ` Peter Zijlstra
2023-07-07 15:39 ` Mike Galbraith
2023-07-07 16:05 ` Peter Zijlstra
2023-07-07 17:28 ` Henry Wu
2023-07-13 12:55 ` Peter Zijlstra
2023-07-14 3:45 ` Henry Wu
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=20230706120103.GJ2833176@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=triangletrap12@gmail.com \
/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
all inboxes | Powered by JetHome®