diff options
| author | Michael Halcrow <mhalcrow@google.com> | 2015-04-14 20:49:49 -0400 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-05-27 19:39:57 +0200 |
| commit | d645a5478cff01c8239c48bd093430bcc7dd12f5 (patch) | |
| tree | 720f729c3e198c6df43fc77ce3b5a0be529fc09c /fs/ext4/file.c | |
| parent | 2d480f4130d304b0a679bfdcb991d503a14f1870 (diff) | |
| download | android_kernel_m2note-d645a5478cff01c8239c48bd093430bcc7dd12f5.tar.gz | |
ext4 crypto: implement the ext4 decryption read path
Change-Id: I66c32c7fa9ad6269f3ea929d773a2b35bccb2290
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Ildar Muslukhov <ildarm@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@google.com>
Diffstat (limited to 'fs/ext4/file.c')
| -rw-r--r-- | fs/ext4/file.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 5833ccfc4..0575ff8c6 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -338,6 +338,13 @@ static const struct vm_operations_struct ext4_file_vm_ops = { static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) { + struct inode *inode = file->f_mapping->host; + + if (ext4_encrypted_inode(inode)) { + int err = ext4_generate_encryption_key(inode); + if (err) + return 0; + } file_accessed(file); vma->vm_ops = &ext4_file_vm_ops; return 0; @@ -350,6 +357,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) struct vfsmount *mnt = filp->f_path.mnt; struct path path; char buf[64], *cp; + int ret; if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) && !(sb->s_flags & MS_RDONLY))) { @@ -388,11 +396,17 @@ static int ext4_file_open(struct inode * inode, struct file * filp) * writing and the journal is present */ if (filp->f_mode & FMODE_WRITE) { - int ret = ext4_inode_attach_jinode(inode); + ret = ext4_inode_attach_jinode(inode); if (ret < 0) return ret; } - return dquot_file_open(inode, filp); + ret = dquot_file_open(inode, filp); + if (!ret && ext4_encrypted_inode(inode)) { + ret = ext4_generate_encryption_key(inode); + if (ret) + ret = -EACCES; + } + return ret; } /* |
