linux/fs/crypto
Eric Biggers e37a784d8b fscrypt: use READ_ONCE() to access ->i_crypt_info
->i_crypt_info starts out NULL and may later be locklessly set to a
non-NULL value by the cmpxchg() in fscrypt_get_encryption_info().

But ->i_crypt_info is used directly, which technically is incorrect.
It's a data race, and it doesn't include the data dependency barrier
needed to safely dereference the pointer on at least one architecture.

Fix this by using READ_ONCE() instead.  Note: we don't need to use
smp_load_acquire(), since dereferencing the pointer only requires a data
dependency barrier, which is already included in READ_ONCE().  We also
don't need READ_ONCE() in places where ->i_crypt_info is unconditionally
dereferenced, since it must have already been checked.

Also downgrade the cmpxchg() to cmpxchg_release(), since RELEASE
semantics are sufficient on the write side.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-16 18:57:09 -04:00
..
bio.c fscrypt: remove WARN_ON_ONCE() when decryption fails 2019-04-16 18:44:44 -04:00
crypto.c fscrypt: use READ_ONCE() to access ->i_crypt_info 2019-04-16 18:57:09 -04:00
fname.c fscrypt: use READ_ONCE() to access ->i_crypt_info 2019-04-16 18:57:09 -04:00
fscrypt_private.h fscrypt: remove filesystem specific build config option 2019-01-23 23:56:43 -05:00
hooks.c fscrypt: return -EXDEV for incompatible rename or link into encrypted dir 2019-01-23 23:56:43 -05:00
Kconfig fscrypt: remove filesystem specific build config option 2019-01-23 23:56:43 -05:00
keyinfo.c fscrypt: use READ_ONCE() to access ->i_crypt_info 2019-04-16 18:57:09 -04:00
Makefile fscrypt: new helper function - fscrypt_file_open() 2017-10-18 19:52:37 -04:00
policy.c fscrypt: use READ_ONCE() to access ->i_crypt_info 2019-04-16 18:57:09 -04:00