From 07ec3feade28bed117a8b1a93595296e723705fa Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Wed, 19 Dec 2018 14:03:14 +1100 Subject: [PATCH] LU-11790 ldiskfs: add terminating u32 when expanding inodes In ext4_expand_extra_isize_ea(), we calculate the total size of the xattr header, plus the xattr entries so we know how much of the beginning part of the xattrs to move when expanding the inode extra size. We need to include the terminating u32 at the end of the xattr entries, or else if there is uninitialized, non-zero bytes after the xattr entries and before the xattr values, the list of xattr entries won't be properly terminated. Signed-off-by: Li Dongyang Change-Id: I247b935b3cf315481dc4658133a7eee02b6350e9 Lustre-change: https://review.whamcloud.com/33893 Lustre-commit: 7c800e460661972925a7acab51f023d0b38161b5 Tested-by: Jenkins Reviewed-by: Yang Sheng Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/34270 Tested-by: Maloo --- ...ze-of-xattr-entries-when-expanding-inodes.patch | 31 ++++++++++++++++++++++ ...ze-of-xattr-entries-when-expanding-inodes.patch | 31 ++++++++++++++++++++++ .../series/ldiskfs-2.6-rhel6.4.series | 1 + .../series/ldiskfs-2.6-rhel6.5.series | 1 + .../series/ldiskfs-2.6-rhel6.6.series | 1 + .../series/ldiskfs-2.6-rhel6.7.series | 1 + .../series/ldiskfs-2.6-rhel6.8.series | 1 + .../series/ldiskfs-2.6-rhel6.9.series | 1 + .../kernel_patches/series/ldiskfs-2.6-rhel6.series | 1 + .../series/ldiskfs-2.6-sles11.series | 1 + .../series/ldiskfs-3.0-sles11.series | 1 + .../series/ldiskfs-3.0-sles11sp3.series | 1 + .../series/ldiskfs-3.0-sles11sp4.series | 1 + .../series/ldiskfs-3.10-rhel7.2.series | 1 + .../series/ldiskfs-3.10-rhel7.3.series | 1 + .../series/ldiskfs-3.10-rhel7.4.series | 1 + .../series/ldiskfs-3.10-rhel7.5.series | 1 + .../series/ldiskfs-3.10-rhel7.6.series | 1 + .../series/ldiskfs-3.10-rhel7.series | 1 + .../series/ldiskfs-3.12-sles12.series | 1 + .../series/ldiskfs-3.12-sles12sp1.series | 1 + .../series/ldiskfs-4.4-sles12sp2.series | 1 + .../series/ldiskfs-4.4-sles12sp3.series | 1 + 23 files changed, 83 insertions(+) create mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch create mode 100644 ldiskfs/kernel_patches/patches/ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch new file mode 100644 index 0000000..4276336 --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch @@ -0,0 +1,31 @@ +Date: Fri, 14 Dec 2018 22:43:43 -0500 +From: "Theodore Ts'o" +List-Id: + +In ext4_expand_extra_isize_ea(), we calculate the total size of the +xattr header, plus the xattr entries so we know how much of the +beginning part of the xattrs to move when expanding the inode extra +size. We need to include the terminating u32 at the end of the xattr +entries, or else if there is uninitialized, non-zero bytes after the +xattr entries and before the xattr values, the list of xattr entries +won't be properly terminated. + +Reported-by: Steve Graham +Signed-off-by: Theodore Ts'o +--- + fs/ext4/xattr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: linux-3.10.0-862.14.4.el7/fs/ext4/xattr.c +=================================================================== +--- linux-3.10.0-862.14.4.el7.orig/fs/ext4/xattr.c ++++ linux-3.10.0-862.14.4.el7/fs/ext4/xattr.c +@@ -1628,7 +1628,7 @@ retry: + end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; + min_offs = end - base; + last = entry; +- total_ino = sizeof(struct ext4_xattr_ibody_header); ++ total_ino = sizeof(struct ext4_xattr_ibody_header) + sizeof(u32); + + ifree = ext4_xattr_free_space(last, &min_offs, base, &total_ino); + if (ifree >= isize_diff) diff --git a/ldiskfs/kernel_patches/patches/ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch b/ldiskfs/kernel_patches/patches/ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch new file mode 100644 index 0000000..3cfbba8 --- /dev/null +++ b/ldiskfs/kernel_patches/patches/ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch @@ -0,0 +1,31 @@ +Date: Fri, 14 Dec 2018 22:43:43 -0500 +From: "Theodore Ts'o" +List-Id: + +In ext4_expand_extra_isize_ea(), we calculate the total size of the +xattr header, plus the xattr entries so we know how much of the +beginning part of the xattrs to move when expanding the inode extra +size. We need to include the terminating u32 at the end of the xattr +entries, or else if there is uninitialized, non-zero bytes after the +xattr entries and before the xattr values, the list of xattr entries +won't be properly terminated. + +Reported-by: Steve Graham +Signed-off-by: Theodore Ts'o +--- + fs/ext4/xattr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c +index 7fddd519adae..86ed9c686249 100644 +--- a/fs/ext4/xattr.c ++++ b/fs/ext4/xattr.c +@@ -2722,7 +2722,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, + base = IFIRST(header); + end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; + min_offs = end - base; +- total_ino = sizeof(struct ext4_xattr_ibody_header); ++ total_ino = sizeof(struct ext4_xattr_ibody_header) + sizeof(u32); + + error = xattr_check_inode(inode, header, end); + if (error) diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series index abf90a6..1431e2a 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series @@ -45,3 +45,4 @@ rhel6.3/ext4-notalloc_under_idatasem.patch rhel6.3/ext4-dont-check-in-ro.patch rhel6.3/ext4-dont-check-before-replay.patch rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series index 970bf52..0253fe2 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series @@ -49,3 +49,4 @@ rhel6.3/ext4-dont-check-in-ro.patch rhel6.3/ext4-dont-check-before-replay.patch rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.6.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.6.series index 4180e13..ebc9b20 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.6.series @@ -49,3 +49,4 @@ rhel6.6/ext4_s_max_ext_tree_depth.patch rhel6.5/ext4-fix-journal-quota.patch rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.7.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.7.series index 015fef2..ce489cc 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.7.series @@ -48,3 +48,4 @@ rhel6.6/ext4_s_max_ext_tree_depth.patch rhel6.5/ext4-fix-journal-quota.patch rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.8.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.8.series index f1ae10d..8a3618c 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.8.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.8.series @@ -46,3 +46,4 @@ rhel6.6/ext4_s_max_ext_tree_depth.patch rhel6.5/ext4-fix-journal-quota.patch rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.9.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.9.series index f4f0a3d..ca6be8d 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.9.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.9.series @@ -45,3 +45,4 @@ rhel6.5/ext4-give-warning-with-dir-htree-growing.patch rhel6.6/ext4_s_max_ext_tree_depth.patch rhel6.5/ext4-fix-journal-quota.patch rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series index 862ee3c..a03fd24 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series @@ -44,3 +44,4 @@ rhel6.3/ext4-notalloc_under_idatasem.patch rhel6.3/ext4-dont-check-in-ro.patch rhel6.3/ext4-dont-check-before-replay.patch rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series index c692f10..283e25b4 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series @@ -44,3 +44,4 @@ rhel6.3/ext4-recalc-percpu-counters-after-journal.patch rhel6.3/ext4-notalloc_under_idatasem.patch rhel6.5/ext4-fix-journal-quota.patch rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series index 1961d04..dc38227 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series @@ -40,3 +40,4 @@ sles11sp3/ext4_s_max_ext_tree_depth.patch sles11sp1/ext4-notalloc_under_idatasem.patch rhel6.5/ext4-fix-journal-quota.patch sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series index 53c2d10..6627c79 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series @@ -44,3 +44,4 @@ rhel6.5/ext4-fix-journal-quota.patch sles11sp3/ext4-dont-check-before-replay.patch rhel6.3/ext4-dont-check-in-ro.patch sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series index e15b624..3cf61cc 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series @@ -44,3 +44,4 @@ rhel6.5/ext4-fix-journal-quota.patch sles11sp3/ext4-dont-check-before-replay.patch rhel6.3/ext4-dont-check-in-ro.patch sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series index 6a38507..63a1665 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series @@ -34,3 +34,4 @@ rhel7/ext4-cleanup-goto-next-group.patch rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series index 0974e8b..7cd4d35 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series @@ -34,3 +34,4 @@ rhel7/ext4-cleanup-goto-next-group.patch rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series index 32c88ca..feeda41 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series @@ -34,3 +34,4 @@ rhel7/ext4-cleanup-goto-next-group.patch rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series index ca60820..9df247a 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series @@ -31,3 +31,4 @@ rhel6.3/ext4-dont-check-in-ro.patch rhel7.4/ext4-dont-check-before-replay.patch rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series index e83274b..0a04968 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series @@ -31,3 +31,4 @@ rhel6.3/ext4-dont-check-in-ro.patch rhel7.6/ext4-dont-check-before-replay.patch rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series index 835a23c..6563ac8 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series @@ -30,3 +30,4 @@ rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch rhel7/ext4-cleanup-goto-next-group.patch rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series index bcc0216..96e9735 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series @@ -21,3 +21,4 @@ rhel7/ext4-give-warning-with-dir-htree-growing.patch rhel7/ext4-mmp-brelse.patch rhel7/ext4-jcb-optimization.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series index 4b622a8..5be3614 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series @@ -22,3 +22,4 @@ rhel7/ext4-mmp-brelse.patch rhel7/ext4-jcb-optimization.patch sles12sp1/ext4-attach-jinode-in-writepages.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series index f2e6460..e5e638c 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series @@ -26,3 +26,4 @@ rhel7.2/ext4-dont-check-in-ro.patch sles12sp2/ext4-fix-xattr-shifting-when-expanding-inodes.patch rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series index 33cabd6..001d035 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series @@ -26,3 +26,4 @@ rhel7.2/ext4-dont-check-in-ro.patch sles12sp2/ext4-fix-xattr-shifting-when-expanding-inodes.patch rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -- 1.8.3.1