2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 18:23:53 +08:00
linux-next/fs/verity
Eric Biggers f3db0bed45 fs-verity: use smp_load_acquire() for ->i_verity_info
Normally smp_store_release() or cmpxchg_release() is paired with
smp_load_acquire().  Sometimes smp_load_acquire() can be replaced with
the more lightweight READ_ONCE().  However, for this to be safe, all the
published memory must only be accessed in a way that involves the
pointer itself.  This may not be the case if allocating the object also
involves initializing a static or global variable, for example.

fsverity_info::tree_params.hash_alg->tfm is a crypto_ahash object that's
internal to and is allocated by the crypto subsystem.  So by using
READ_ONCE() for ->i_verity_info, we're relying on internal
implementation details of the crypto subsystem.

Remove this fragile assumption by using smp_load_acquire() instead.

Also fix the cmpxchg logic to correctly execute an ACQUIRE barrier when
losing the cmpxchg race, since cmpxchg doesn't guarantee a memory
barrier on failure.

(Note: I haven't seen any real-world problems here.  This change is just
fixing the code to be guaranteed correct and less fragile.)

Fixes: fd2d1acfca ("fs-verity: add the hook for file ->open()")
Link: https://lore.kernel.org/r/20200721225920.114347-6-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2020-07-21 16:02:41 -07:00
..
enable.c fs-verity: fix all kerneldoc warnings 2020-05-12 16:43:59 -07:00
fsverity_private.h fs-verity: remove unnecessary extern keywords 2020-05-12 16:44:00 -07:00
hash_algs.c fs-verity: use mempool for hash requests 2020-01-14 13:28:05 -08:00
init.c fs-verity: support builtin file signatures 2019-08-12 19:33:50 -07:00
Kconfig fs-verity: support builtin file signatures 2019-08-12 19:33:50 -07:00
Makefile fs-verity: support builtin file signatures 2019-08-12 19:33:50 -07:00
measure.c fs-verity: fix all kerneldoc warnings 2020-05-12 16:43:59 -07:00
open.c fs-verity: use smp_load_acquire() for ->i_verity_info 2020-07-21 16:02:41 -07:00
signature.c fs-verity: fix all kerneldoc warnings 2020-05-12 16:43:59 -07:00
verify.c fs-verity: fix all kerneldoc warnings 2020-05-12 16:43:59 -07:00