summaryrefslogtreecommitdiffstats
path: root/security/yama
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-10-29 06:30:19 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-10-31 13:49:25 -0400
commita0b3bc855374c50b5ea85273553485af48caf2f7 (patch)
tree8ca729595e38cb85062c8640a2a334647bfd4843 /security/yama
parentf4f864c1219cd88c01fd6359ffc870da9b4acf92 (diff)
downloadlinux-a0b3bc855374c50b5ea85273553485af48caf2f7.tar.gz
linux-a0b3bc855374c50b5ea85273553485af48caf2f7.tar.bz2
linux-a0b3bc855374c50b5ea85273553485af48caf2f7.zip
fscrypt: lock mutex before checking for bounce page pool
fscrypt_initialize(), which allocates the global bounce page pool when an encrypted file is first accessed, uses "double-checked locking" to try to avoid locking fscrypt_init_mutex. However, it doesn't use any memory barriers, so it's theoretically possible for a thread to observe a bounce page pool which has not been fully initialized. This is a classic bug with "double-checked locking". While "only a theoretical issue" in the latest kernel, in pre-4.8 kernels the pointer that was checked was not even the last to be initialized, so it was easily possible for a crash (NULL pointer dereference) to happen. This was changed only incidentally by the large refactor to use fs/crypto/. Solve both problems in a trivial way that can easily be backported: just always take the mutex. It's theoretically less efficient, but it shouldn't be noticeable in practice as the mutex is only acquired very briefly once per encrypted file. Later I'd like to make this use a helper macro like DO_ONCE(). However, DO_ONCE() runs in atomic context, so we'd need to add a new macro that allows blocking. Cc: stable@vger.kernel.org # v4.1+ Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'security/yama')
0 files changed, 0 insertions, 0 deletions