From: Michael Halcrow Date: Wed, 8 Apr 2015 04:19:28 +0000 (-0400) Subject: ext4 crypto: inherit encryption policies on inode and directory create X-Git-Tag: KARO-TXA5-2015-06-26~116^2~10 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=132a56928baef1d7d7e9cfd86abd251e29b95007;p=karo-tx-linux.git ext4 crypto: inherit encryption policies on inode and directory create Change-Id: Ibeeafc70352b39d1d5b3b17158a41d8fb54ed136 Signed-off-by: Michael Halcrow Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 30cd7dec2015..1db188ed783f 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -47,6 +47,8 @@ #define NAMEI_RA_BLOCKS 4 #define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS) +static int ext4_unlink(struct inode *dir, struct dentry *dentry); + static struct buffer_head *ext4_append(handle_t *handle, struct inode *inode, ext4_lblk_t *block) @@ -2251,6 +2253,13 @@ retry: err = ext4_add_nondir(handle, dentry, inode); if (!err && IS_DIRSYNC(dir)) ext4_handle_sync(handle); +#ifdef CONFIG_EXT4_FS_ENCRYPTION + if (!err && ext4_encrypted_inode(dir)) { + err = ext4_inherit_context(dir, inode); + if (err) + ext4_unlink(dir, dentry); + } +#endif } if (handle) ext4_journal_stop(handle); @@ -2452,6 +2461,13 @@ out_clear_inode: d_instantiate(dentry, inode); if (IS_DIRSYNC(dir)) ext4_handle_sync(handle); +#ifdef CONFIG_EXT4_FS_ENCRYPTION + if (ext4_encrypted_inode(dir)) { + err = ext4_inherit_context(dir, inode); + if (err) + ext4_unlink(dir, dentry); + } +#endif out_stop: if (handle)