summaryrefslogtreecommitdiffstats
path: root/fs/ext4/file.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-10-18 20:21:57 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-10-18 20:21:57 -0400
commit09a5c31c919da0a83d3fa9fffaa09cf78cc2d466 (patch)
tree51920b0e48dde0cbeac929c7e4d90de11505ed6e /fs/ext4/file.c
parent815dac33b27da9efce0f6008272e69f2a1ba1a33 (diff)
downloadlinux-stable-09a5c31c919da0a83d3fa9fffaa09cf78cc2d466.tar.gz
linux-stable-09a5c31c919da0a83d3fa9fffaa09cf78cc2d466.tar.bz2
linux-stable-09a5c31c919da0a83d3fa9fffaa09cf78cc2d466.zip
ext4: switch to fscrypt_file_open()
Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r--fs/ext4/file.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index b1da660ac3bc..ffe9144088f8 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -364,7 +364,6 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
struct super_block *sb = inode->i_sb;
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
struct vfsmount *mnt = filp->f_path.mnt;
- struct dentry *dir;
struct path path;
char buf[64], *cp;
int ret;
@@ -404,25 +403,11 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
ext4_journal_stop(handle);
}
}
- if (ext4_encrypted_inode(inode)) {
- ret = fscrypt_get_encryption_info(inode);
- if (ret)
- return -EACCES;
- if (!fscrypt_has_encryption_key(inode))
- return -ENOKEY;
- }
- dir = dget_parent(file_dentry(filp));
- if (ext4_encrypted_inode(d_inode(dir)) &&
- !fscrypt_has_permitted_context(d_inode(dir), inode)) {
- ext4_warning(inode->i_sb,
- "Inconsistent encryption contexts: %lu/%lu",
- (unsigned long) d_inode(dir)->i_ino,
- (unsigned long) inode->i_ino);
- dput(dir);
- return -EPERM;
- }
- dput(dir);
+ ret = fscrypt_file_open(inode, filp);
+ if (ret)
+ return ret;
+
/*
* Set up the jbd2_inode if we are opening the inode for
* writing and the journal is present