summaryrefslogtreecommitdiffstats
path: root/fs/ext4/namei.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 21:35:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 21:35:55 -0400
commit396d10993f8d2ef410a6ca6a42724dc0211a8b42 (patch)
treeb28e4cfe46162077803e1e2d13471edf6532b722 /fs/ext4/namei.c
parent59ebc44e8dac359812f317473c4f05cd1432f5d2 (diff)
parent7bc9491645118c9461bd21099c31755ff6783593 (diff)
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: "The major change this cycle is deleting ext4's copy of the file system encryption code and switching things over to using the copies in fs/crypto. I've updated the MAINTAINERS file to add an entry for fs/crypto listing Jaeguk Kim and myself as the maintainers. There are also a number of bug fixes, most notably for some problems found by American Fuzzy Lop (AFL) courtesy of Vegard Nossum. Also fixed is a writeback deadlock detected by generic/130, and some potential races in the metadata checksum code" * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (21 commits) ext4: verify extent header depth ext4: short-cut orphan cleanup on error ext4: fix reference counting bug on block allocation error MAINTAINRES: fs-crypto maintainers update ext4 crypto: migrate into vfs's crypto engine ext2: fix filesystem deadlock while reading corrupted xattr block ext4: fix project quota accounting without quota limits enabled ext4: validate s_reserved_gdt_blocks on mount ext4: remove unused page_idx ext4: don't call ext4_should_journal_data() on the journal inode ext4: Fix WARN_ON_ONCE in ext4_commit_super() ext4: fix deadlock during page writeback ext4: correct error value of function verifying dx checksum ext4: avoid modifying checksum fields directly during checksum verification ext4: check for extents that wrap around jbd2: make journal y2038 safe jbd2: track more dependencies on transaction commit jbd2: move lockdep tracking to journal_s jbd2: move lockdep instrumentation for jbd2 handles ext4: respect the nobarrier mount option in nojournal mode ...
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r--fs/ext4/namei.c144
1 files changed, 69 insertions, 75 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 6569c6b47da4..34c0142caf6a 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -420,15 +420,14 @@ static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
420 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 420 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
421 struct ext4_inode_info *ei = EXT4_I(inode); 421 struct ext4_inode_info *ei = EXT4_I(inode);
422 __u32 csum; 422 __u32 csum;
423 __le32 save_csum;
424 int size; 423 int size;
424 __u32 dummy_csum = 0;
425 int offset = offsetof(struct dx_tail, dt_checksum);
425 426
426 size = count_offset + (count * sizeof(struct dx_entry)); 427 size = count_offset + (count * sizeof(struct dx_entry));
427 save_csum = t->dt_checksum;
428 t->dt_checksum = 0;
429 csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size); 428 csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
430 csum = ext4_chksum(sbi, csum, (__u8 *)t, sizeof(struct dx_tail)); 429 csum = ext4_chksum(sbi, csum, (__u8 *)t, offset);
431 t->dt_checksum = save_csum; 430 csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
432 431
433 return cpu_to_le32(csum); 432 return cpu_to_le32(csum);
434} 433}
@@ -446,14 +445,14 @@ static int ext4_dx_csum_verify(struct inode *inode,
446 c = get_dx_countlimit(inode, dirent, &count_offset); 445 c = get_dx_countlimit(inode, dirent, &count_offset);
447 if (!c) { 446 if (!c) {
448 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D."); 447 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D.");
449 return 1; 448 return 0;
450 } 449 }
451 limit = le16_to_cpu(c->limit); 450 limit = le16_to_cpu(c->limit);
452 count = le16_to_cpu(c->count); 451 count = le16_to_cpu(c->count);
453 if (count_offset + (limit * sizeof(struct dx_entry)) > 452 if (count_offset + (limit * sizeof(struct dx_entry)) >
454 EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) { 453 EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) {
455 warn_no_space_for_csum(inode); 454 warn_no_space_for_csum(inode);
456 return 1; 455 return 0;
457 } 456 }
458 t = (struct dx_tail *)(((struct dx_entry *)c) + limit); 457 t = (struct dx_tail *)(((struct dx_entry *)c) + limit);
459 458
@@ -612,19 +611,19 @@ static struct stats dx_show_leaf(struct inode *dir,
612#ifdef CONFIG_EXT4_FS_ENCRYPTION 611#ifdef CONFIG_EXT4_FS_ENCRYPTION
613 int len; 612 int len;
614 char *name; 613 char *name;
615 struct ext4_str fname_crypto_str 614 struct fscrypt_str fname_crypto_str =
616 = {.name = NULL, .len = 0}; 615 FSTR_INIT(NULL, 0);
617 int res = 0; 616 int res = 0;
618 617
619 name = de->name; 618 name = de->name;
620 len = de->name_len; 619 len = de->name_len;
621 if (ext4_encrypted_inode(inode)) 620 if (ext4_encrypted_inode(dir))
622 res = ext4_get_encryption_info(dir); 621 res = fscrypt_get_encryption_info(dir);
623 if (res) { 622 if (res) {
624 printk(KERN_WARNING "Error setting up" 623 printk(KERN_WARNING "Error setting up"
625 " fname crypto: %d\n", res); 624 " fname crypto: %d\n", res);
626 } 625 }
627 if (ctx == NULL) { 626 if (!fscrypt_has_encryption_key(dir)) {
628 /* Directory is not encrypted */ 627 /* Directory is not encrypted */
629 ext4fs_dirhash(de->name, 628 ext4fs_dirhash(de->name,
630 de->name_len, &h); 629 de->name_len, &h);
@@ -633,19 +632,21 @@ static struct stats dx_show_leaf(struct inode *dir,
633 (unsigned) ((char *) de 632 (unsigned) ((char *) de
634 - base)); 633 - base));
635 } else { 634 } else {
635 struct fscrypt_str de_name =
636 FSTR_INIT(name, len);
637
636 /* Directory is encrypted */ 638 /* Directory is encrypted */
637 res = ext4_fname_crypto_alloc_buffer( 639 res = fscrypt_fname_alloc_buffer(
638 ctx, de->name_len, 640 dir, len,
639 &fname_crypto_str); 641 &fname_crypto_str);
640 if (res < 0) { 642 if (res < 0)
641 printk(KERN_WARNING "Error " 643 printk(KERN_WARNING "Error "
642 "allocating crypto " 644 "allocating crypto "
643 "buffer--skipping " 645 "buffer--skipping "
644 "crypto\n"); 646 "crypto\n");
645 ctx = NULL; 647 res = fscrypt_fname_disk_to_usr(dir,
646 } 648 0, 0, &de_name,
647 res = ext4_fname_disk_to_usr(ctx, NULL, de, 649 &fname_crypto_str);
648 &fname_crypto_str);
649 if (res < 0) { 650 if (res < 0) {
650 printk(KERN_WARNING "Error " 651 printk(KERN_WARNING "Error "
651 "converting filename " 652 "converting filename "
@@ -662,8 +663,8 @@ static struct stats dx_show_leaf(struct inode *dir,
662 printk("%*.s:(E)%x.%u ", len, name, 663 printk("%*.s:(E)%x.%u ", len, name,
663 h.hash, (unsigned) ((char *) de 664 h.hash, (unsigned) ((char *) de
664 - base)); 665 - base));
665 ext4_fname_crypto_free_buffer( 666 fscrypt_fname_free_buffer(
666 &fname_crypto_str); 667 &fname_crypto_str);
667 } 668 }
668#else 669#else
669 int len = de->name_len; 670 int len = de->name_len;
@@ -952,7 +953,7 @@ static int htree_dirblock_to_tree(struct file *dir_file,
952 struct buffer_head *bh; 953 struct buffer_head *bh;
953 struct ext4_dir_entry_2 *de, *top; 954 struct ext4_dir_entry_2 *de, *top;
954 int err = 0, count = 0; 955 int err = 0, count = 0;
955 struct ext4_str fname_crypto_str = {.name = NULL, .len = 0}, tmp_str; 956 struct fscrypt_str fname_crypto_str = FSTR_INIT(NULL, 0), tmp_str;
956 957
957 dxtrace(printk(KERN_INFO "In htree dirblock_to_tree: block %lu\n", 958 dxtrace(printk(KERN_INFO "In htree dirblock_to_tree: block %lu\n",
958 (unsigned long)block)); 959 (unsigned long)block));
@@ -967,12 +968,12 @@ static int htree_dirblock_to_tree(struct file *dir_file,
967#ifdef CONFIG_EXT4_FS_ENCRYPTION 968#ifdef CONFIG_EXT4_FS_ENCRYPTION
968 /* Check if the directory is encrypted */ 969 /* Check if the directory is encrypted */
969 if (ext4_encrypted_inode(dir)) { 970 if (ext4_encrypted_inode(dir)) {
970 err = ext4_get_encryption_info(dir); 971 err = fscrypt_get_encryption_info(dir);
971 if (err < 0) { 972 if (err < 0) {
972 brelse(bh); 973 brelse(bh);
973 return err; 974 return err;
974 } 975 }
975 err = ext4_fname_crypto_alloc_buffer(dir, EXT4_NAME_LEN, 976 err = fscrypt_fname_alloc_buffer(dir, EXT4_NAME_LEN,
976 &fname_crypto_str); 977 &fname_crypto_str);
977 if (err < 0) { 978 if (err < 0) {
978 brelse(bh); 979 brelse(bh);
@@ -1003,10 +1004,13 @@ static int htree_dirblock_to_tree(struct file *dir_file,
1003 &tmp_str); 1004 &tmp_str);
1004 } else { 1005 } else {
1005 int save_len = fname_crypto_str.len; 1006 int save_len = fname_crypto_str.len;
1007 struct fscrypt_str de_name = FSTR_INIT(de->name,
1008 de->name_len);
1006 1009
1007 /* Directory is encrypted */ 1010 /* Directory is encrypted */
1008 err = ext4_fname_disk_to_usr(dir, hinfo, de, 1011 err = fscrypt_fname_disk_to_usr(dir, hinfo->hash,
1009 &fname_crypto_str); 1012 hinfo->minor_hash, &de_name,
1013 &fname_crypto_str);
1010 if (err < 0) { 1014 if (err < 0) {
1011 count = err; 1015 count = err;
1012 goto errout; 1016 goto errout;
@@ -1025,7 +1029,7 @@ static int htree_dirblock_to_tree(struct file *dir_file,
1025errout: 1029errout:
1026 brelse(bh); 1030 brelse(bh);
1027#ifdef CONFIG_EXT4_FS_ENCRYPTION 1031#ifdef CONFIG_EXT4_FS_ENCRYPTION
1028 ext4_fname_crypto_free_buffer(&fname_crypto_str); 1032 fscrypt_fname_free_buffer(&fname_crypto_str);
1029#endif 1033#endif
1030 return count; 1034 return count;
1031} 1035}
@@ -1050,7 +1054,7 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
1050 int count = 0; 1054 int count = 0;
1051 int ret, err; 1055 int ret, err;
1052 __u32 hashval; 1056 __u32 hashval;
1053 struct ext4_str tmp_str; 1057 struct fscrypt_str tmp_str;
1054 1058
1055 dxtrace(printk(KERN_DEBUG "In htree_fill_tree, start hash: %x:%x\n", 1059 dxtrace(printk(KERN_DEBUG "In htree_fill_tree, start hash: %x:%x\n",
1056 start_hash, start_minor_hash)); 1060 start_hash, start_minor_hash));
@@ -1564,26 +1568,23 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
1564 struct ext4_dir_entry_2 *de; 1568 struct ext4_dir_entry_2 *de;
1565 struct buffer_head *bh; 1569 struct buffer_head *bh;
1566 1570
1567 if (ext4_encrypted_inode(dir)) { 1571 if (ext4_encrypted_inode(dir)) {
1568 int res = ext4_get_encryption_info(dir); 1572 int res = fscrypt_get_encryption_info(dir);
1569 1573
1570 /* 1574 /*
1571 * This should be a properly defined flag for 1575 * DCACHE_ENCRYPTED_WITH_KEY is set if the dentry is
1572 * dentry->d_flags when we uplift this to the VFS.
1573 * d_fsdata is set to (void *) 1 if if the dentry is
1574 * created while the directory was encrypted and we 1576 * created while the directory was encrypted and we
1575 * don't have access to the key. 1577 * have access to the key.
1576 */ 1578 */
1577 dentry->d_fsdata = NULL; 1579 if (fscrypt_has_encryption_key(dir))
1578 if (ext4_encryption_info(dir)) 1580 fscrypt_set_encrypted_dentry(dentry);
1579 dentry->d_fsdata = (void *) 1; 1581 fscrypt_set_d_op(dentry);
1580 d_set_d_op(dentry, &ext4_encrypted_d_ops); 1582 if (res && res != -ENOKEY)
1581 if (res && res != -ENOKEY) 1583 return ERR_PTR(res);
1582 return ERR_PTR(res); 1584 }
1583 }
1584 1585
1585 if (dentry->d_name.len > EXT4_NAME_LEN) 1586 if (dentry->d_name.len > EXT4_NAME_LEN)
1586 return ERR_PTR(-ENAMETOOLONG); 1587 return ERR_PTR(-ENAMETOOLONG);
1587 1588
1588 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); 1589 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
1589 if (IS_ERR(bh)) 1590 if (IS_ERR(bh))
@@ -1610,11 +1611,9 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
1610 } 1611 }
1611 if (!IS_ERR(inode) && ext4_encrypted_inode(dir) && 1612 if (!IS_ERR(inode) && ext4_encrypted_inode(dir) &&
1612 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && 1613 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
1613 !ext4_is_child_context_consistent_with_parent(dir, 1614 !fscrypt_has_permitted_context(dir, inode)) {
1614 inode)) {
1615 int nokey = ext4_encrypted_inode(inode) && 1615 int nokey = ext4_encrypted_inode(inode) &&
1616 !ext4_encryption_info(inode); 1616 !fscrypt_has_encryption_key(inode);
1617
1618 iput(inode); 1617 iput(inode);
1619 if (nokey) 1618 if (nokey)
1620 return ERR_PTR(-ENOKEY); 1619 return ERR_PTR(-ENOKEY);
@@ -2691,30 +2690,30 @@ out_stop:
2691/* 2690/*
2692 * routine to check that the specified directory is empty (for rmdir) 2691 * routine to check that the specified directory is empty (for rmdir)
2693 */ 2692 */
2694int ext4_empty_dir(struct inode *inode) 2693bool ext4_empty_dir(struct inode *inode)
2695{ 2694{
2696 unsigned int offset; 2695 unsigned int offset;
2697 struct buffer_head *bh; 2696 struct buffer_head *bh;
2698 struct ext4_dir_entry_2 *de, *de1; 2697 struct ext4_dir_entry_2 *de, *de1;
2699 struct super_block *sb; 2698 struct super_block *sb;
2700 int err = 0;
2701 2699
2702 if (ext4_has_inline_data(inode)) { 2700 if (ext4_has_inline_data(inode)) {
2703 int has_inline_data = 1; 2701 int has_inline_data = 1;
2702 int ret;
2704 2703
2705 err = empty_inline_dir(inode, &has_inline_data); 2704 ret = empty_inline_dir(inode, &has_inline_data);
2706 if (has_inline_data) 2705 if (has_inline_data)
2707 return err; 2706 return ret;
2708 } 2707 }
2709 2708
2710 sb = inode->i_sb; 2709 sb = inode->i_sb;
2711 if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)) { 2710 if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)) {
2712 EXT4_ERROR_INODE(inode, "invalid size"); 2711 EXT4_ERROR_INODE(inode, "invalid size");
2713 return 1; 2712 return true;
2714 } 2713 }
2715 bh = ext4_read_dirblock(inode, 0, EITHER); 2714 bh = ext4_read_dirblock(inode, 0, EITHER);
2716 if (IS_ERR(bh)) 2715 if (IS_ERR(bh))
2717 return 1; 2716 return true;
2718 2717
2719 de = (struct ext4_dir_entry_2 *) bh->b_data; 2718 de = (struct ext4_dir_entry_2 *) bh->b_data;
2720 de1 = ext4_next_entry(de, sb->s_blocksize); 2719 de1 = ext4_next_entry(de, sb->s_blocksize);
@@ -2723,7 +2722,7 @@ int ext4_empty_dir(struct inode *inode)
2723 strcmp(".", de->name) || strcmp("..", de1->name)) { 2722 strcmp(".", de->name) || strcmp("..", de1->name)) {
2724 ext4_warning_inode(inode, "directory missing '.' and/or '..'"); 2723 ext4_warning_inode(inode, "directory missing '.' and/or '..'");
2725 brelse(bh); 2724 brelse(bh);
2726 return 1; 2725 return true;
2727 } 2726 }
2728 offset = ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize) + 2727 offset = ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize) +
2729 ext4_rec_len_from_disk(de1->rec_len, sb->s_blocksize); 2728 ext4_rec_len_from_disk(de1->rec_len, sb->s_blocksize);
@@ -2731,12 +2730,11 @@ int ext4_empty_dir(struct inode *inode)
2731 while (offset < inode->i_size) { 2730 while (offset < inode->i_size) {
2732 if ((void *) de >= (void *) (bh->b_data+sb->s_blocksize)) { 2731 if ((void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
2733 unsigned int lblock; 2732 unsigned int lblock;
2734 err = 0;
2735 brelse(bh); 2733 brelse(bh);
2736 lblock = offset >> EXT4_BLOCK_SIZE_BITS(sb); 2734 lblock = offset >> EXT4_BLOCK_SIZE_BITS(sb);
2737 bh = ext4_read_dirblock(inode, lblock, EITHER); 2735 bh = ext4_read_dirblock(inode, lblock, EITHER);
2738 if (IS_ERR(bh)) 2736 if (IS_ERR(bh))
2739 return 1; 2737 return true;
2740 de = (struct ext4_dir_entry_2 *) bh->b_data; 2738 de = (struct ext4_dir_entry_2 *) bh->b_data;
2741 } 2739 }
2742 if (ext4_check_dir_entry(inode, NULL, de, bh, 2740 if (ext4_check_dir_entry(inode, NULL, de, bh,
@@ -2748,13 +2746,13 @@ int ext4_empty_dir(struct inode *inode)
2748 } 2746 }
2749 if (le32_to_cpu(de->inode)) { 2747 if (le32_to_cpu(de->inode)) {
2750 brelse(bh); 2748 brelse(bh);
2751 return 0; 2749 return false;
2752 } 2750 }
2753 offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize); 2751 offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize);
2754 de = ext4_next_entry(de, sb->s_blocksize); 2752 de = ext4_next_entry(de, sb->s_blocksize);
2755 } 2753 }
2756 brelse(bh); 2754 brelse(bh);
2757 return 1; 2755 return true;
2758} 2756}
2759 2757
2760/* 2758/*
@@ -3077,8 +3075,8 @@ static int ext4_symlink(struct inode *dir,
3077 int err, len = strlen(symname); 3075 int err, len = strlen(symname);
3078 int credits; 3076 int credits;
3079 bool encryption_required; 3077 bool encryption_required;
3080 struct ext4_str disk_link; 3078 struct fscrypt_str disk_link;
3081 struct ext4_encrypted_symlink_data *sd = NULL; 3079 struct fscrypt_symlink_data *sd = NULL;
3082 3080
3083 disk_link.len = len + 1; 3081 disk_link.len = len + 1;
3084 disk_link.name = (char *) symname; 3082 disk_link.name = (char *) symname;
@@ -3086,13 +3084,13 @@ static int ext4_symlink(struct inode *dir,
3086 encryption_required = (ext4_encrypted_inode(dir) || 3084 encryption_required = (ext4_encrypted_inode(dir) ||
3087 DUMMY_ENCRYPTION_ENABLED(EXT4_SB(dir->i_sb))); 3085 DUMMY_ENCRYPTION_ENABLED(EXT4_SB(dir->i_sb)));
3088 if (encryption_required) { 3086 if (encryption_required) {
3089 err = ext4_get_encryption_info(dir); 3087 err = fscrypt_get_encryption_info(dir);
3090 if (err) 3088 if (err)
3091 return err; 3089 return err;
3092 if (ext4_encryption_info(dir) == NULL) 3090 if (!fscrypt_has_encryption_key(dir))
3093 return -EPERM; 3091 return -EPERM;
3094 disk_link.len = (ext4_fname_encrypted_size(dir, len) + 3092 disk_link.len = (fscrypt_fname_encrypted_size(dir, len) +
3095 sizeof(struct ext4_encrypted_symlink_data)); 3093 sizeof(struct fscrypt_symlink_data));
3096 sd = kzalloc(disk_link.len, GFP_KERNEL); 3094 sd = kzalloc(disk_link.len, GFP_KERNEL);
3097 if (!sd) 3095 if (!sd)
3098 return -ENOMEM; 3096 return -ENOMEM;
@@ -3140,13 +3138,12 @@ static int ext4_symlink(struct inode *dir,
3140 3138
3141 if (encryption_required) { 3139 if (encryption_required) {
3142 struct qstr istr; 3140 struct qstr istr;
3143 struct ext4_str ostr; 3141 struct fscrypt_str ostr =
3142 FSTR_INIT(sd->encrypted_path, disk_link.len);
3144 3143
3145 istr.name = (const unsigned char *) symname; 3144 istr.name = (const unsigned char *) symname;
3146 istr.len = len; 3145 istr.len = len;
3147 ostr.name = sd->encrypted_path; 3146 err = fscrypt_fname_usr_to_disk(inode, &istr, &ostr);
3148 ostr.len = disk_link.len;
3149 err = ext4_fname_usr_to_disk(inode, &istr, &ostr);
3150 if (err < 0) 3147 if (err < 0)
3151 goto err_drop_inode; 3148 goto err_drop_inode;
3152 sd->len = cpu_to_le16(ostr.len); 3149 sd->len = cpu_to_le16(ostr.len);
@@ -3235,7 +3232,7 @@ static int ext4_link(struct dentry *old_dentry,
3235 if (inode->i_nlink >= EXT4_LINK_MAX) 3232 if (inode->i_nlink >= EXT4_LINK_MAX)
3236 return -EMLINK; 3233 return -EMLINK;
3237 if (ext4_encrypted_inode(dir) && 3234 if (ext4_encrypted_inode(dir) &&
3238 !ext4_is_child_context_consistent_with_parent(dir, inode)) 3235 !fscrypt_has_permitted_context(dir, inode))
3239 return -EPERM; 3236 return -EPERM;
3240 3237
3241 if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) && 3238 if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) &&
@@ -3558,8 +3555,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3558 3555
3559 if ((old.dir != new.dir) && 3556 if ((old.dir != new.dir) &&
3560 ext4_encrypted_inode(new.dir) && 3557 ext4_encrypted_inode(new.dir) &&
3561 !ext4_is_child_context_consistent_with_parent(new.dir, 3558 !fscrypt_has_permitted_context(new.dir, old.inode)) {
3562 old.inode)) {
3563 retval = -EPERM; 3559 retval = -EPERM;
3564 goto end_rename; 3560 goto end_rename;
3565 } 3561 }
@@ -3731,10 +3727,8 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
3731 if ((ext4_encrypted_inode(old_dir) || 3727 if ((ext4_encrypted_inode(old_dir) ||
3732 ext4_encrypted_inode(new_dir)) && 3728 ext4_encrypted_inode(new_dir)) &&
3733 (old_dir != new_dir) && 3729 (old_dir != new_dir) &&
3734 (!ext4_is_child_context_consistent_with_parent(new_dir, 3730 (!fscrypt_has_permitted_context(new_dir, old.inode) ||
3735 old.inode) || 3731 !fscrypt_has_permitted_context(old_dir, new.inode)))
3736 !ext4_is_child_context_consistent_with_parent(old_dir,
3737 new.inode)))
3738 return -EPERM; 3732 return -EPERM;
3739 3733
3740 if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) && 3734 if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&