diff options
| author | Michael Halcrow <mhalcrow@google.com> | 2015-04-14 20:47:49 -0400 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-05-27 19:39:57 +0200 |
| commit | 6313292f3f2b10b62b898c5ea9f84ef3841c249e (patch) | |
| tree | 3b277a976b6cc5da4ea595ba774bcd7254be8f06 | |
| parent | 00c67522e667d095b5a3d6159b37a3a85e871bbe (diff) | |
ext4 crypto: inherit encryption policies on inode and directory create
Change-Id: I117081ed17bd60e76b3bc938daf1404ceffb94c2
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@google.com>
| -rw-r--r-- | fs/ext4/namei.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 1a5903e8b..a88b8b4ee 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2249,9 +2249,20 @@ retry: inode->i_op = &ext4_file_inode_operations; inode->i_fop = &ext4_file_operations; ext4_set_aops(inode); - err = ext4_add_nondir(handle, dentry, inode); + err = 0; +#ifdef CONFIG_EXT4_FS_ENCRYPTION + if (!err && ext4_encrypted_inode(dir)) + err = ext4_inherit_context(dir, inode); +#endif + if (!err) + err = ext4_add_nondir(handle, dentry, inode); if (!err && IS_DIRSYNC(dir)) ext4_handle_sync(handle); + if (err) { + clear_nlink(inode); + unlock_new_inode(inode); + iput(inode); + } } if (handle) ext4_journal_stop(handle); @@ -2432,6 +2443,13 @@ retry: err = ext4_init_new_dir(handle, dir, inode); if (err) goto out_clear_inode; +#ifdef CONFIG_EXT4_FS_ENCRYPTION + if (ext4_encrypted_inode(dir)) { + err = ext4_inherit_context(dir, inode); + if (err) + goto out_clear_inode; + } +#endif err = ext4_mark_inode_dirty(handle, inode); if (!err) err = ext4_add_entry(handle, dentry, inode); |
