Re: [PATCH] pstore: Revert pmsg_lock back to a normal mutex

From: Steven Rostedt
Date: Thu Mar 02 2023 - 17:13:42 EST


On Thu, 2 Mar 2023 16:32:53 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> CPU1 CPU2
> ---- ----
> rt_mutex_slowlock_block() {
> raw_spin_lock_irq(wait_lock);
> owner = rt_mutex_owner();
> raw_spin_unlock_irq(wait_lock);
>
> rtmutex_spin_on_owner(owner) {

I just noticed there's an rcu_read_lock() here around the loop.
I'm guessing that's to keep this race from happening.
Would have been nice to have a comment there stating such.

-- Steve

> owner = rt_mutex_owner();
>
> [ task preempted! (could also be a long interrupt) ]
>
> owner releases lock and exits
> owner is freed
>
> [ task resumes ]
>
> if (!owner_on_cpu(owner)
>
> READ_ONCE(owner->on_cpu)
> *** BOOM invalid pointer dereference ***