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 PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 14 Jan 2020 13:17:45 -0500 From: Waiman Long <longman@...hat.com> To: Christoph Hellwig <hch@....de>, linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>, Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>, linux-ext4@...r.kernel.org, cluster-devel@...hat.com Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org Subject: Re: [PATCH 02/12] locking/rwsem: Exit early when held by an anonymous owner On 1/14/20 11:12 AM, Christoph Hellwig wrote: > The rwsem code overloads the owner field with either a task struct or > negative magic numbers. Add a quick hack to catch these negative > values early on. Without this spinning on a writer that replaced the > owner with RWSEM_OWNER_UNKNOWN, rwsem_spin_on_owner can crash while > deferencing the task_struct ->on_cpu field of a -8 value. > > XXX: This might be a bit of a hack as the code otherwise doesn't use > the ERR_PTR family macros, better suggestions welcome. > > Signed-off-by: Christoph Hellwig <hch@....de> > --- > kernel/locking/rwsem.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c > index 44e68761f432..6adc719a30a1 100644 > --- a/kernel/locking/rwsem.c > +++ b/kernel/locking/rwsem.c > @@ -725,6 +725,8 @@ rwsem_spin_on_owner(struct rw_semaphore *sem, unsigned long nonspinnable) > state = rwsem_owner_state(owner, flags, nonspinnable); > if (state != OWNER_WRITER) > return state; > + if (IS_ERR(owner)) > + return state; > > rcu_read_lock(); > for (;;) { The owner field is just a pointer to the task structure with the lower 3 bits served as flag bits. Setting owner to RWSEM_OWNER_UNKNOWN (-2) will stop optimistic spinning. So under what condition did the crash happen? Anyway, PeterZ is working on revising the percpu-rwsem implementation to more gracefully handle the frozen case. At the end, there will not be a need for the RWSEM_OWNER_UNKNOWN magic and it can be removed. Cheers, Longman RWSEM_OWNER_UNKNOWN
Powered by blists - more mailing lists