fscrypt: avoid data race on fscrypt_mode::logged_impl_name
authorEric Biggers <ebiggers@google.com>
Mon, 21 Oct 2019 20:49:03 +0000 (13:49 -0700)
committerEric Biggers <ebiggers@google.com>
Wed, 6 Nov 2019 20:33:15 +0000 (12:33 -0800)
commitff73c2c016f8569b728eb1e9ebfab383545e4d65
tree878f712c354b45c9d251da651ab4b3440e175ba2
parent065ab4c4701ff6e28785eb8172925fc3068cc15e
fscrypt: avoid data race on fscrypt_mode::logged_impl_name

The access to logged_impl_name is technically a data race, which tools
like KCSAN could complain about in the future.  See:
https://github.com/google/ktsan/wiki/READ_ONCE-and-WRITE_ONCE

Fix by using xchg(), which also ensures that only one thread does the
logging.

This also required switching from bool to int, to avoid a build error on
the RISC-V architecture which doesn't implement xchg on bytes.

Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/fscrypt_private.h
fs/crypto/keysetup.c