aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2016-09-29 14:00:38 -0400
committerRichard Weinberger <richard@nod.at>2016-12-12 17:07:38 -0500
commitac7e47a9ed1b22b1c71345fcdec35a5d2727ef2c (patch)
treeffa8f90b4ce1941a5391905198ced19275502db4 /fs/ubifs
parenta79bff21c120a615dc8ba6df9258e9e2ef022e3b (diff)
ubifs: Enforce crypto policy in ->link and ->rename
When a file is moved or linked into another directory its current crypto policy has to be compatible with the target policy. Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/dir.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 477817567971..bd0af4e9ca0b 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -639,6 +639,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
639 ubifs_assert(inode_is_locked(dir)); 639 ubifs_assert(inode_is_locked(dir));
640 ubifs_assert(inode_is_locked(inode)); 640 ubifs_assert(inode_is_locked(inode));
641 641
642 if (ubifs_crypt_is_encrypted(dir) &&
643 !fscrypt_has_permitted_context(dir, inode))
644 return -EPERM;
645
642 err = dbg_check_synced_i_size(c, inode); 646 err = dbg_check_synced_i_size(c, inode);
643 if (err) 647 if (err)
644 return err; 648 return err;
@@ -1133,6 +1137,12 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
1133 if (unlink) 1137 if (unlink)
1134 ubifs_assert(inode_is_locked(new_inode)); 1138 ubifs_assert(inode_is_locked(new_inode));
1135 1139
1140 if (old_dir != new_dir) {
1141 if (ubifs_crypt_is_encrypted(new_dir) &&
1142 !fscrypt_has_permitted_context(new_dir, old_inode))
1143 return -EPERM;
1144 }
1145
1136 if (unlink && is_dir) { 1146 if (unlink && is_dir) {
1137 err = ubifs_check_dir_empty(new_inode); 1147 err = ubifs_check_dir_empty(new_inode);
1138 if (err) 1148 if (err)
@@ -1327,6 +1337,13 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
1327 1337
1328 ubifs_assert(fst_inode && snd_inode); 1338 ubifs_assert(fst_inode && snd_inode);
1329 1339
1340 if ((ubifs_crypt_is_encrypted(old_dir) ||
1341 ubifs_crypt_is_encrypted(new_dir)) &&
1342 (old_dir != new_dir) &&
1343 (!fscrypt_has_permitted_context(new_dir, fst_inode) ||
1344 !fscrypt_has_permitted_context(old_dir, snd_inode)))
1345 return -EPERM;
1346
1330 lock_4_inodes(old_dir, new_dir, NULL, NULL); 1347 lock_4_inodes(old_dir, new_dir, NULL, NULL);
1331 1348
1332 time = ubifs_current_time(old_dir); 1349 time = ubifs_current_time(old_dir);