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: <20191121194418.GA239776@google.com>
Date:   Thu, 21 Nov 2019 20:44:18 +0100
From:   Marco Elver <elver@...gle.com>
To:     Ingo Molnar <mingo@...nel.org>
Cc:     peterz@...radead.org, mingo@...hat.com, will@...nel.org,
        linux-kernel@...r.kernel.org, Qian Cai <cai@....pw>,
        Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH] spinlock_debug: Fix various data races

On Thu, 21 Nov 2019, Ingo Molnar wrote:

> 
> * Marco Elver <elver@...gle.com> wrote:
> 
> >  static inline void debug_spin_lock_after(raw_spinlock_t *lock)
> >  {
> > -	lock->owner_cpu = raw_smp_processor_id();
> > -	lock->owner = current;
> > +	WRITE_ONCE(lock->owner_cpu, raw_smp_processor_id());
> > +	WRITE_ONCE(lock->owner, current);
> >  }
> 
> debug_spin_lock_after() runs inside the spinlock itself - why do these 
> writes have to be WRITE_ONCE()?
> 
> > @@ -197,8 +197,8 @@ static inline void debug_write_unlock(rwlock_t *lock)
> >  	RWLOCK_BUG_ON(lock->owner != current, lock, "wrong owner");
> >  	RWLOCK_BUG_ON(lock->owner_cpu != raw_smp_processor_id(),
> >  							lock, "wrong CPU");
> > -	lock->owner = SPINLOCK_OWNER_INIT;
> > -	lock->owner_cpu = -1;
> > +	WRITE_ONCE(lock->owner, SPINLOCK_OWNER_INIT);
> > +	WRITE_ONCE(lock->owner_cpu, -1);
> >  }
> 
> This too is running inside the critical section of the spinlock - why are 
> the WRITE_ONCE() calls necessary?

Although the writes are inside the critical section, they are read
concurrently outside the critical section, e.g. in
debug_spin_lock_before(). In other words, the WRITE_ONCE pair with the
READ_ONCE that are *outside* the critical section.

Thanks,
-- Marco

> Thanks,
> 
> 	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ