linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-fscrypt@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] fscrypt: add memory barrier when loading essiv_hash_tfm
Date: Mon, 18 Mar 2019 10:24:54 -0700	[thread overview]
Message-ID: <20190318172454.240412-1-ebiggers@kernel.org> (raw)

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


             reply	other threads:[~2019-03-18 17:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18 17:24 Eric Biggers [this message]
2019-04-11 21:37 ` [PATCH] fscrypt: add memory barrier when loading essiv_hash_tfm Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190318172454.240412-1-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).