fscrypt: use ENOKEY when file cannot be created w/o key
authorEric Biggers <ebiggers@google.com>
Mon, 5 Dec 2016 19:12:44 +0000 (11:12 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Nov 2017 08:39:11 +0000 (08:39 +0000)
commitd612bee05b031e6cac5606aff6e95ce7cd8104e4
tree9ef9a04d06ee1c63fac970899747953c1ca8343e
parente7918c60da9c1d081f3f19cb46301b04e1f085c9
fscrypt: use ENOKEY when file cannot be created w/o key

[ Upstream commit 54475f531bb8d7078f63c159e5e0615d486c498c ]

As part of an effort to clean up fscrypt-related error codes, make
attempting to create a file in an encrypted directory that hasn't been
"unlocked" fail with ENOKEY.  Previously, several error codes were used
for this case, including ENOENT, EACCES, and EPERM, and they were not
consistent between and within filesystems.  ENOKEY is a better choice
because it expresses that the failure is due to lacking the encryption
key.  It also matches the error code returned when trying to open an
encrypted regular file without the key.

I am not aware of any users who might be relying on the previous
inconsistent error codes, which were never documented anywhere.

This failure case will be exercised by an xfstest.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/crypto/fname.c
fs/ext4/ialloc.c
fs/ext4/namei.c
fs/f2fs/dir.c
fs/f2fs/namei.c