mbox series

[0/5] fscrypt, fs-verity: one-time init fixes

Message ID 20200721225920.114347-1-ebiggers@kernel.org (mailing list archive)
Headers show
Series fscrypt, fs-verity: one-time init fixes | expand

Message

Eric Biggers July 21, 2020, 10:59 p.m. UTC
This series fixes up some cases in fs/crypto/ and fs/verity/ where
"one-time init" is implemented using READ_ONCE() instead of
smp_load_acquire() but it's not obviously correct.

One case is fixed by using a better approach that removes the need to
initialize anything.  The others are fixed by upgrading READ_ONCE() to
smp_load_acquire().  I've also improved the comments.

This is motivated by the discussions at 
https://lkml.kernel.org/linux-fsdevel/20200713033330.205104-1-ebiggers@kernel.org/T/#u
and
https://lkml.kernel.org/linux-fsdevel/20200717044427.68747-1-ebiggers@kernel.org/T/#u

These fixes are improvements over the status quo, so I'd prefer to apply
them now, without waiting for any potential new generic one-time-init
macros (which based on the latest discussion, won't be flexible enough
to handle most of these cases anyway).

Eric Biggers (5):
  fscrypt: switch fscrypt_do_sha256() to use the SHA-256 library
  fscrypt: use smp_load_acquire() for fscrypt_prepared_key
  fscrypt: use smp_load_acquire() for ->s_master_keys
  fscrypt: use smp_load_acquire() for ->i_crypt_info
  fs-verity: use smp_load_acquire() for ->i_verity_info

 fs/crypto/Kconfig           |  2 +-
 fs/crypto/fname.c           | 41 +++++++++----------------------------
 fs/crypto/fscrypt_private.h | 15 ++++++++------
 fs/crypto/inline_crypt.c    |  6 ++++--
 fs/crypto/keyring.c         | 15 +++++++++++---
 fs/crypto/keysetup.c        | 18 +++++++++++++---
 fs/crypto/policy.c          |  4 ++--
 fs/verity/open.c            | 15 +++++++++++---
 include/linux/fscrypt.h     | 29 +++++++++++++++++++++-----
 include/linux/fsverity.h    |  9 ++++++--
 10 files changed, 96 insertions(+), 58 deletions(-)

Comments

Eric Biggers July 27, 2020, 4:38 p.m. UTC | #1
On Tue, Jul 21, 2020 at 03:59:15PM -0700, Eric Biggers wrote:
> This series fixes up some cases in fs/crypto/ and fs/verity/ where
> "one-time init" is implemented using READ_ONCE() instead of
> smp_load_acquire() but it's not obviously correct.
> 
> One case is fixed by using a better approach that removes the need to
> initialize anything.  The others are fixed by upgrading READ_ONCE() to
> smp_load_acquire().  I've also improved the comments.
> 
> This is motivated by the discussions at 
> https://lkml.kernel.org/linux-fsdevel/20200713033330.205104-1-ebiggers@kernel.org/T/#u
> and
> https://lkml.kernel.org/linux-fsdevel/20200717044427.68747-1-ebiggers@kernel.org/T/#u
> 
> These fixes are improvements over the status quo, so I'd prefer to apply
> them now, without waiting for any potential new generic one-time-init
> macros (which based on the latest discussion, won't be flexible enough
> to handle most of these cases anyway).
> 
> Eric Biggers (5):
>   fscrypt: switch fscrypt_do_sha256() to use the SHA-256 library
>   fscrypt: use smp_load_acquire() for fscrypt_prepared_key
>   fscrypt: use smp_load_acquire() for ->s_master_keys
>   fscrypt: use smp_load_acquire() for ->i_crypt_info
>   fs-verity: use smp_load_acquire() for ->i_verity_info
> 
>  fs/crypto/Kconfig           |  2 +-
>  fs/crypto/fname.c           | 41 +++++++++----------------------------
>  fs/crypto/fscrypt_private.h | 15 ++++++++------
>  fs/crypto/inline_crypt.c    |  6 ++++--
>  fs/crypto/keyring.c         | 15 +++++++++++---
>  fs/crypto/keysetup.c        | 18 +++++++++++++---
>  fs/crypto/policy.c          |  4 ++--
>  fs/verity/open.c            | 15 +++++++++++---
>  include/linux/fscrypt.h     | 29 +++++++++++++++++++++-----
>  include/linux/fsverity.h    |  9 ++++++--
>  10 files changed, 96 insertions(+), 58 deletions(-)

Patches 1-4 applied to fscrypt.git#master for 5.9.
Patch 5 applied to fscrypt.git#fsverity for 5.9.

- Eric