lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250624125358.25a7d4cd5ea02ea0bbe373a6@kernel.org>
Date: Tue, 24 Jun 2025 12:53:58 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Lance Yang <lance.yang@...ux.dev>
Cc: akpm@...ux-foundation.org, zi.li@...ux.dev, anna.schumaker@...cle.com,
 boqun.feng@...il.com, joel.granados@...nel.org, jstultz@...gle.com,
 kent.overstreet@...ux.dev, leonylgao@...cent.com,
 linux-kernel@...r.kernel.org, longman@...hat.com, mingo@...hat.com,
 mingzhe.yang@...com, peterz@...radead.org, rostedt@...dmis.org,
 senozhatsky@...omium.org, tfiga@...omium.org, will@...nel.org, Lance Yang
 <ioworker0@...il.com>
Subject: Re: [PATCH RFC 2/3] locking/rwsem: clear reader-owner on unlock to
 reduce false positives

On Tue, 24 Jun 2025 09:44:55 +0800
Lance Yang <lance.yang@...ux.dev> wrote:

> 
> 
> On 2025/6/24 08:26, Masami Hiramatsu (Google) wrote:
> > On Thu, 12 Jun 2025 12:19:25 +0800
> > Lance Yang <ioworker0@...il.com> wrote:
> > 
> >> From: Lance Yang <lance.yang@...ux.dev>
> >>
> >> When CONFIG_DETECT_HUNG_TASK_BLOCKER is enabled, a stale owner pointer in a
> >> reader-owned rwsem can lead to false positives in blocker tracking.
> >>
> >> To mitigate this, let’s try to clear the owner field on unlock, as a NULL
> >> owner is better than a stale one for diagnostics.
> > 
> > Can we merge this to [PATCH 1/3]? It seems that you removed #ifdef and
> > remove it. This means in anyway we need the feature enabled by DEBUG_RWSEMS.
> 
> Thanks for the feedback! I see your point about the dependency ;)
> 
> Personlly, I'd perfer to keep them separate. The reasoning is that
> they addreess two distinct things, and I think splitting them makes
> this series clearer and easier to review ;)
> 
> Patch #1 focuses on "ownership tracking": Its only job is to make
> the existing owner-related helpers (rwsem_owner(), is_rwsem_reader_owned())
> globally available when blocker tracking is enabled.
> 
> Patch #2, on the other hand, is about "reader-owner cleanup": It
> introduces a functional change to the unlock path, trying to clear
> the owner field for reader-owned rwsems.

But without clearing the owner, the owner information can be
broken, right? Since CONFIG_DEBUG_RWSEMS is working as it is,
I think those cannot be decoupled. For example, comparing the
result of both DETECT_HUNG_TASK_BLOCKER and DEBUG_RWSEMS are
enabled and only DETECT_HUNG_TASK_BLOCKER is enabled, the
result is different.

> 
> Does this reasoning make sense to you?

Sorry, no. I think "reader-owner cleanup" is a part of "ownership
tracking" as DEBUG_RWSEMS does (and that keeps consistency of
the ownership tracking behavior same as DEBUG_RWSEM).

Thank you,

> 
> Thanks,
> Lance
> 
> > 
> > Thanks,
> > 
> >>
> >> Signed-off-by: Lance Yang <lance.yang@...ux.dev>
> >> ---
> >>   kernel/locking/rwsem.c | 10 ++++------
> >>   1 file changed, 4 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
> >> index 6cb29442d4fc..a310eb9896de 100644
> >> --- a/kernel/locking/rwsem.c
> >> +++ b/kernel/locking/rwsem.c
> >> @@ -205,14 +205,12 @@ bool is_rwsem_reader_owned(struct rw_semaphore *sem)
> >>   		return false;
> >>   	return rwsem_test_oflags(sem, RWSEM_READER_OWNED);
> >>   }
> >> -#endif
> >>   
> >> -#ifdef CONFIG_DEBUG_RWSEMS
> >>   /*
> >> - * With CONFIG_DEBUG_RWSEMS configured, it will make sure that if there
> >> - * is a task pointer in owner of a reader-owned rwsem, it will be the
> >> - * real owner or one of the real owners. The only exception is when the
> >> - * unlock is done by up_read_non_owner().
> >> + * With CONFIG_DEBUG_RWSEMS or CONFIG_DETECT_HUNG_TASK_BLOCKER configured,
> >> + * it will make sure that the owner field of a reader-owned rwsem either
> >> + * points to a real reader-owner(s) or gets cleared. The only exception is
> >> + * when the unlock is done by up_read_non_owner().
> >>    */
> >>   static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem)
> >>   {
> >> -- 
> >> 2.49.0
> >>
> > 
> > 
> 


-- 
Masami Hiramatsu (Google) <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ