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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171023134622.GE3165@worktop.lehotels.local>
Date:   Mon, 23 Oct 2017 15:46:22 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Mark Rutland <mark.rutland@....com>
Cc:     linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH] locking/spinlock/debug: snapshot lock fields

On Mon, Oct 23, 2017 at 01:29:10PM +0100, Mark Rutland wrote:
> Currently, the lock debug code doesn't use {READ,WRITE}_ONCE() to access
> lock fields, and thus may observe torn values given a suitably unhelpful
> compiler. These could result in false positives and/or false negatives
> for some sanity checks.
> 
> Further, as we don't snapshot the values of various fields, these might
> change between the time they are sanity checked and the time they are
> logged, making debugging difficult.
> 
> This patch ensures that lock fields are accessed with
> {READ,WRITE}_ONCE(), and uses a snapshot of the lock to ensure that
> logged values are the same as those used for the sanity checks.
> 
> Signed-off-by: Mark Rutland <mark.rutland@....com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Ingo Molnar <mingo@...hat.com>

ACK, I'll try and remember to look at this if there's anything further
we can remove from this file.

> +static inline raw_spinlock_t
> +debug_spin_lock_snapshot(raw_spinlock_t *lockp)
> +{
> +	raw_spinlock_t lock;
> +
> +	lock.raw_lock = READ_ONCE(lockp->raw_lock);

I think you want to make that an smp_load_acquire(), such that we
preserve the release-acquire relation for the lock.

Since this happens _before_ the regular lock, but debug_spin_unlock()
also happens before the regular unlock. So the unlock release is still
placed right. But we've messed up our acquire.

> +	lock.magic = READ_ONCE(lockp->magic);
> +	lock.owner_cpu = READ_ONCE(lockp->owner_cpu);
> +	lock.owner = READ_ONCE(lockp->owner);
> +
> +	return lock;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ