ext4 crypto: make sure the encryption info is initialized on opendir(2)
authorTheodore Ts'o <tytso@mit.edu>
Sun, 31 May 2015 17:34:57 +0000 (13:34 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 31 May 2015 17:34:57 +0000 (13:34 -0400)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/dir.c

index e11e6ae26baa6546a37a5a4e75b373df37349afb..f9e14911918ced4ca6b81ca913a6b60a5e997a5c 100644 (file)
@@ -593,6 +593,13 @@ finished:
        return 0;
 }
 
+static int ext4_dir_open(struct inode * inode, struct file * filp)
+{
+       if (ext4_encrypted_inode(inode))
+               return ext4_get_encryption_info(inode) ? -EACCES : 0;
+       return 0;
+}
+
 static int ext4_release_dir(struct inode *inode, struct file *filp)
 {
        if (filp->private_data)
@@ -635,5 +642,6 @@ const struct file_operations ext4_dir_operations = {
        .compat_ioctl   = ext4_compat_ioctl,
 #endif
        .fsync          = ext4_sync_file,
+       .open           = ext4_dir_open,
        .release        = ext4_release_dir,
 };