ext4: fix use-after-iput when fscrypt contexts are inconsistent

am: 68ca0fdac4

Change-Id: Ib125136b30c773718c8c2ec4e4a504da0ff92cbd
This commit is contained in:
Eric Biggers
2017-03-12 08:21:57 +00:00
committed by android-build-merger

View File

@@ -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);
}
}