All of lore.kernel.org
 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,
	linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-mtd@lists.infradead.org, linux-unionfs@vger.kernel.org,
	Sarthak Kukreti <sarthakkukreti@chromium.org>,
	Gao Xiang <gaoxiang25@huawei.com>
Subject: Re: [PATCH v2 5/5] fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext
Date: Wed, 17 Apr 2019 10:24:35 -0400	[thread overview]
Message-ID: <20190417142435.GE4686@mit.edu> (raw)
In-Reply-To: <20190320183913.12686-6-ebiggers@kernel.org>

On Wed, Mar 20, 2019 at 11:39:13AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> ->lookup() in an encrypted directory begins as follows:
> 
> 1. fscrypt_prepare_lookup():
>     a. Try to load the directory's encryption key.
>     b. If the key is unavailable, mark the dentry as a ciphertext name
>        via d_flags.
> 2. fscrypt_setup_filename():
>     a. Try to load the directory's encryption key.
>     b. If the key is available, encrypt the name (treated as a plaintext
>        name) to get the on-disk name.  Otherwise decode the name
>        (treated as a ciphertext name) to get the on-disk name.
> 
> But if the key is concurrently added, it may be found at (2a) but not at
> (1a).  In this case, the dentry will be wrongly marked as a ciphertext
> name even though it was actually treated as plaintext.
> 
> This will cause the dentry to be wrongly invalidated on the next lookup,
> potentially causing problems.  For example, if the racy ->lookup() was
> part of sys_mount(), then the new mount will be detached when anything
> tries to access it.  This is despite the mountpoint having a plaintext
> path, which should remain valid now that the key was added.
> 
> Of course, this is only possible if there's a userspace race.  Still,
> the additional kernel-side race is confusing and unexpected.
> 
> Close the kernel-side race by changing fscrypt_prepare_lookup() to also
> set the on-disk filename (step 2b), consistent with the d_flags update.
> 
> Fixes: 28b4c263961c ("ext4 crypto: revalidate dentry after adding or removing the key")
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Looks good, applied.

					- Ted

WARNING: multiple messages have this Message-ID (diff)
From: "Theodore Ts'o" <tytso@mit.edu>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-unionfs@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-fscrypt@vger.kernel.org, linux-mtd@lists.infradead.org,
	Sarthak Kukreti <sarthakkukreti@chromium.org>,
	linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v2 5/5] fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext
Date: Wed, 17 Apr 2019 10:24:35 -0400	[thread overview]
Message-ID: <20190417142435.GE4686@mit.edu> (raw)
In-Reply-To: <20190320183913.12686-6-ebiggers@kernel.org>

On Wed, Mar 20, 2019 at 11:39:13AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> ->lookup() in an encrypted directory begins as follows:
> 
> 1. fscrypt_prepare_lookup():
>     a. Try to load the directory's encryption key.
>     b. If the key is unavailable, mark the dentry as a ciphertext name
>        via d_flags.
> 2. fscrypt_setup_filename():
>     a. Try to load the directory's encryption key.
>     b. If the key is available, encrypt the name (treated as a plaintext
>        name) to get the on-disk name.  Otherwise decode the name
>        (treated as a ciphertext name) to get the on-disk name.
> 
> But if the key is concurrently added, it may be found at (2a) but not at
> (1a).  In this case, the dentry will be wrongly marked as a ciphertext
> name even though it was actually treated as plaintext.
> 
> This will cause the dentry to be wrongly invalidated on the next lookup,
> potentially causing problems.  For example, if the racy ->lookup() was
> part of sys_mount(), then the new mount will be detached when anything
> tries to access it.  This is despite the mountpoint having a plaintext
> path, which should remain valid now that the key was added.
> 
> Of course, this is only possible if there's a userspace race.  Still,
> the additional kernel-side race is confusing and unexpected.
> 
> Close the kernel-side race by changing fscrypt_prepare_lookup() to also
> set the on-disk filename (step 2b), consistent with the d_flags update.
> 
> Fixes: 28b4c263961c ("ext4 crypto: revalidate dentry after adding or removing the key")
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Looks good, applied.

					- Ted

WARNING: multiple messages have this Message-ID (diff)
From: "Theodore Ts'o" <tytso@mit.edu>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Gao Xiang <gaoxiang25@huawei.com>,
	linux-unionfs@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-fscrypt@vger.kernel.org, linux-mtd@lists.infradead.org,
	Sarthak Kukreti <sarthakkukreti@chromium.org>,
	linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v2 5/5] fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext
Date: Wed, 17 Apr 2019 10:24:35 -0400	[thread overview]
Message-ID: <20190417142435.GE4686@mit.edu> (raw)
In-Reply-To: <20190320183913.12686-6-ebiggers@kernel.org>

On Wed, Mar 20, 2019 at 11:39:13AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> ->lookup() in an encrypted directory begins as follows:
> 
> 1. fscrypt_prepare_lookup():
>     a. Try to load the directory's encryption key.
>     b. If the key is unavailable, mark the dentry as a ciphertext name
>        via d_flags.
> 2. fscrypt_setup_filename():
>     a. Try to load the directory's encryption key.
>     b. If the key is available, encrypt the name (treated as a plaintext
>        name) to get the on-disk name.  Otherwise decode the name
>        (treated as a ciphertext name) to get the on-disk name.
> 
> But if the key is concurrently added, it may be found at (2a) but not at
> (1a).  In this case, the dentry will be wrongly marked as a ciphertext
> name even though it was actually treated as plaintext.
> 
> This will cause the dentry to be wrongly invalidated on the next lookup,
> potentially causing problems.  For example, if the racy ->lookup() was
> part of sys_mount(), then the new mount will be detached when anything
> tries to access it.  This is despite the mountpoint having a plaintext
> path, which should remain valid now that the key was added.
> 
> Of course, this is only possible if there's a userspace race.  Still,
> the additional kernel-side race is confusing and unexpected.
> 
> Close the kernel-side race by changing fscrypt_prepare_lookup() to also
> set the on-disk filename (step 2b), consistent with the d_flags update.
> 
> Fixes: 28b4c263961c ("ext4 crypto: revalidate dentry after adding or removing the key")
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Looks good, applied.

					- Ted

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2019-04-17 14:25 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 18:39 [PATCH v2 0/5] fscrypt: d_revalidate fixes and cleanups Eric Biggers
2019-03-20 18:39 ` Eric Biggers
2019-03-20 18:39 ` Eric Biggers
2019-03-20 18:39 ` [PATCH v2 1/5] fscrypt: clean up and improve dentry revalidation Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-03-20 18:39   ` [f2fs-dev] " Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-04-16 23:08   ` Theodore Ts'o
2019-04-16 23:08     ` Theodore Ts'o
2019-04-17  0:10     ` Eric Biggers
2019-04-17  0:10       ` Eric Biggers
2019-04-17  0:10       ` [f2fs-dev] " Eric Biggers
2019-04-17  0:10       ` Eric Biggers
2019-04-17 13:50       ` Theodore Ts'o
2019-04-17 13:50         ` Theodore Ts'o
2019-04-17 13:50         ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 2/5] fscrypt: fix race allowing rename() and link() of ciphertext dentries Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-03-20 18:39   ` [f2fs-dev] " Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-04-17 13:53   ` Theodore Ts'o
2019-04-17 13:53     ` Theodore Ts'o
2019-04-17 13:53     ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 3/5] fs, fscrypt: clear DCACHE_ENCRYPTED_NAME when unaliasing directory Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-04-17 14:06   ` Theodore Ts'o
2019-04-17 14:06     ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 4/5] fscrypt: only set dentry_operations on ciphertext dentries Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-03-20 18:39   ` [f2fs-dev] " Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-04-17 14:07   ` Theodore Ts'o
2019-04-17 14:07     ` Theodore Ts'o
2019-04-17 14:07     ` Theodore Ts'o
2019-03-20 18:39 ` [PATCH v2 5/5] fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-03-20 18:39   ` [f2fs-dev] " Eric Biggers
2019-03-20 18:39   ` Eric Biggers
2019-04-17 14:24   ` Theodore Ts'o [this message]
2019-04-17 14:24     ` Theodore Ts'o
2019-04-17 14:24     ` Theodore Ts'o
2019-04-01 17:11 ` [PATCH v2 0/5] fscrypt: d_revalidate fixes and cleanups Eric Biggers
2019-04-01 17:11   ` Eric Biggers
2019-04-01 17:11   ` [f2fs-dev] " Eric Biggers
2019-04-01 17:11   ` Eric Biggers
2019-04-08  8:22   ` Richard Weinberger
2019-04-08  8:22     ` Richard Weinberger
2019-04-08  8:22     ` Richard Weinberger

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=20190417142435.GE4686@mit.edu \
    --to=tytso@mit.edu \
    --cc=ebiggers@kernel.org \
    --cc=gaoxiang25@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=sarthakkukreti@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.