diff options
author | Eric Biggers <ebiggers@google.com> | 2017-02-01 21:07:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-12 06:44:13 +0100 |
commit | c9bcbdfebb1fb52eb2b4087b5d6a50499e7fcba6 (patch) | |
tree | 5f6db230bf2321314036c90d068441761237b657 /fs | |
parent | c8f246b40261373b74b44e660824dee5b997312c (diff) | |
download | linux-stable-c9bcbdfebb1fb52eb2b4087b5d6a50499e7fcba6.tar.gz linux-stable-c9bcbdfebb1fb52eb2b4087b5d6a50499e7fcba6.tar.bz2 linux-stable-c9bcbdfebb1fb52eb2b4087b5d6a50499e7fcba6.zip |
ext4: fix use-after-iput when fscrypt contexts are inconsistent
commit dd01b690f8f4b1e414f89e5a9a5326bf720d6652 upstream.
In the case where the child's encryption context was inconsistent with
its parent directory, we were using inode->i_sb and inode->i_ino after
the inode had already been iput(). Fix this by doing the iput() in the
correct places.
Note: only ext4 had this bug, not f2fs and ubifs.
Fixes: d9cdc9033181 ("ext4 crypto: enforce context consistency")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/namei.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index eadba919f26b..2fbc63d697e9 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1616,13 +1616,15 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi !fscrypt_has_permitted_context(dir, inode)) { int nokey = ext4_encrypted_inode(inode) && !fscrypt_has_encryption_key(inode); - iput(inode); - if (nokey) + if (nokey) { + iput(inode); return ERR_PTR(-ENOKEY); + } ext4_warning(inode->i_sb, "Inconsistent encryption contexts: %lu/%lu", (unsigned long) dir->i_ino, (unsigned long) inode->i_ino); + iput(inode); return ERR_PTR(-EPERM); } } |