linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] fscrypt: use READ_ONCE() to access ->i_crypt_info
Date: Tue, 16 Apr 2019 18:57:25 -0400	[thread overview]
Message-ID: <20190416225725.GA14623@mit.edu> (raw)
In-Reply-To: <20190411213215.163929-1-ebiggers@kernel.org>

On Thu, Apr 11, 2019 at 02:32:15PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> ->i_crypt_info starts out NULL and may later be locklessly set to a
> non-NULL value by the cmpxchg() in fscrypt_get_encryption_info().
> 
> But ->i_crypt_info is used directly, which technically is incorrect.
> It's a data race, and it doesn't include the data dependency barrier
> needed to safely dereference the pointer on at least one architecture.
> 
> Fix this by using READ_ONCE() instead.  Note: we don't need to use
> smp_load_acquire(), since dereferencing the pointer only requires a data
> dependency barrier, which is already included in READ_ONCE().  We also
> don't need READ_ONCE() in places where ->i_crypt_info is unconditionally
> dereferenced, since it must have already been checked.
> 
> Also downgrade the cmpxchg() to cmpxchg_release(), since RELEASE
> semantics are sufficient on the write side.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Looks good, applied.

					- Ted

      reply	other threads:[~2019-04-16 22:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 21:32 [PATCH v2] fscrypt: use READ_ONCE() to access ->i_crypt_info Eric Biggers
2019-04-16 22:57 ` Theodore Ts'o [this message]

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=20190416225725.GA14623@mit.edu \
    --to=tytso@mit.edu \
    --cc=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).