linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fscrypt: add memory barrier when loading essiv_hash_tfm
@ 2019-03-18 17:24 Eric Biggers
  2019-04-11 21:37 ` Eric Biggers
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2019-03-18 17:24 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: linux-fsdevel

From: Eric Biggers <ebiggers@google.com>

Load 'essiv_hash_tfm' using smp_load_acquire() to guarantee that the
struct crypto_shash is seen as fully initialized before being used.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/crypto/keyinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index ba74dafa18a3..d1f0f8369d51 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -379,7 +379,7 @@ fscrypt_get_master_key(const struct fscrypt_info *ci, struct fscrypt_mode *mode,
 
 static int derive_essiv_salt(const u8 *key, int keysize, u8 *salt)
 {
-	struct crypto_shash *tfm = READ_ONCE(essiv_hash_tfm);
+	struct crypto_shash *tfm = smp_load_acquire(&essiv_hash_tfm);
 
 	/* init hash transform on demand */
 	if (unlikely(!tfm)) {
-- 
2.21.0.225.g810b269d1ac-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fscrypt: add memory barrier when loading essiv_hash_tfm
  2019-03-18 17:24 [PATCH] fscrypt: add memory barrier when loading essiv_hash_tfm Eric Biggers
@ 2019-04-11 21:37 ` Eric Biggers
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2019-04-11 21:37 UTC (permalink / raw)
  To: linux-fscrypt; +Cc: linux-fsdevel

On Mon, Mar 18, 2019 at 10:24:54AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> Load 'essiv_hash_tfm' using smp_load_acquire() to guarantee that the
> struct crypto_shash is seen as fully initialized before being used.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  fs/crypto/keyinfo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
> index ba74dafa18a3..d1f0f8369d51 100644
> --- a/fs/crypto/keyinfo.c
> +++ b/fs/crypto/keyinfo.c
> @@ -379,7 +379,7 @@ fscrypt_get_master_key(const struct fscrypt_info *ci, struct fscrypt_mode *mode,
>  
>  static int derive_essiv_salt(const u8 *key, int keysize, u8 *salt)
>  {
> -	struct crypto_shash *tfm = READ_ONCE(essiv_hash_tfm);
> +	struct crypto_shash *tfm = smp_load_acquire(&essiv_hash_tfm);
>  
>  	/* init hash transform on demand */
>  	if (unlikely(!tfm)) {
> -- 
> 2.21.0.225.g810b269d1ac-goog
> 

Actually I think we only need a data dependency barrier here, so this patch
isn't needed.  See discussion of similar case at
https://marc.info/?l=linux-fsdevel&m=155487269904655&w=2

- Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-11 21:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 17:24 [PATCH] fscrypt: add memory barrier when loading essiv_hash_tfm Eric Biggers
2019-04-11 21:37 ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).