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.
Lustre-change: https://review.whamcloud.com/33893
Lustre-commit:
7c800e460661972925a7acab51f023d0b38161b5
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Change-Id: I247b935b3cf315481dc4658133a7eee02b6350e9
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/34314
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
--- /dev/null
+Date: Fri, 14 Dec 2018 22:43:43 -0500
+From: "Theodore Ts'o" <tytso@mit.edu>
+List-Id: <linux-ext4.vger.kernel.org>
+
+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 <stgraham2000@gmail.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ 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)
--- /dev/null
+Date: Fri, 14 Dec 2018 22:43:43 -0500
+From: "Theodore Ts'o" <tytso@mit.edu>
+List-Id: <linux-ext4.vger.kernel.org>
+
+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 <stgraham2000@gmail.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ 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)
rhel6.3/ext4-dont-check-before-replay.patch
rhel7/ext4-export-orphan-add.patch
rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch
rhel7/ext4-export-orphan-add.patch
rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch
rhel7/ext4-export-orphan-add.patch
rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch
rhel7/ext4-export-orphan-add.patch
rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.5/ext4-brackets-in-ext4-remove-blocks.patch
rhel7/ext4-export-orphan-add.patch
rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.5/ext4-fix-journal-quota.patch
rhel7/ext4-export-orphan-add.patch
rhel6.6/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.3/ext4-dont-check-before-replay.patch
rhel7/ext4-export-orphan-add.patch
rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.5/ext4-fix-journal-quota.patch
rhel7/ext4-export-orphan-add.patch
rhel6.3/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.5/ext4-fix-journal-quota.patch
rhel7/ext4-export-orphan-add.patch
sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.3/ext4-dont-check-in-ro.patch
rhel7/ext4-export-orphan-add.patch
sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel6.3/ext4-dont-check-in-ro.patch
rhel7/ext4-export-orphan-add.patch
sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-jcb-optimization.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
sles12sp1/ext4-attach-jinode-in-writepages.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
sles12sp2/ext4-fix-xattr-shifting-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch
rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch
rhel7/ext4-export-orphan-add.patch
rhel7/ext4-mmp-dont-mark-bh-dirty.patch
+rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch