]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
f2fs: prevent creating duplicate encrypted filenames
authorEric Biggers <ebiggers@google.com>
Mon, 28 Dec 2020 19:12:10 +0000 (11:12 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Jan 2021 13:44:58 +0000 (14:44 +0100)
commit218cf245fc6a3aacb0ebe143a4f4a88121104559
tree6d4522bdf7d3fcec3cdf2940d1118c0ff1857a7e
parentabd561e51a2a36eca2f1858b95ccaa613637d162
f2fs: prevent creating duplicate encrypted filenames

commit bfc2b7e8518999003a61f91c1deb5e88ed77b07d upstream.

As described in "fscrypt: add fscrypt_is_nokey_name()", it's possible to
create a duplicate filename in an encrypted directory by creating a file
concurrently with adding the directory's encryption key.

Fix this bug on f2fs by rejecting no-key dentries in f2fs_add_link().

Note that the weird check for the current task in f2fs_do_add_link()
seems to make this bug difficult to reproduce on f2fs.

Fixes: 9ea97163c6da ("f2fs crypto: add filename encryption for f2fs_add_link")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20201118075609.120337-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/f2fs/f2fs.h