ext4: fix use-after-iput when fscrypt contexts are inconsistent
authorEric Biggers <ebiggers@google.com>
Thu, 2 Feb 2017 02:07:11 +0000 (21:07 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Mar 2017 05:44:13 +0000 (06:44 +0100)
commitc9bcbdfebb1fb52eb2b4087b5d6a50499e7fcba6
tree5f6db230bf2321314036c90d068441761237b657
parentc8f246b40261373b74b44e660824dee5b997312c
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>
fs/ext4/namei.c