!86 [sync] PR-85: fixed xfstests case failures
From: @openeuler-sync-bot Reviewed-by: @liuzhiqiang26 Signed-off-by: @liuzhiqiang26
This commit is contained in:
commit
0b6d55387d
@ -0,0 +1,61 @@
|
|||||||
|
From baf8a5df8a0c6539818a3f78a68d22648c022e50 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Darrick J. Wong" <djwong@kernel.org>
|
||||||
|
Date: Tue, 12 Jul 2022 13:25:33 -0500
|
||||||
|
Subject: [PATCH] xfs_copy: don't use cached buffer reads until after
|
||||||
|
libxfs_mount
|
||||||
|
|
||||||
|
I accidentally tried to xfs_copy an ext4 filesystem, but instead of
|
||||||
|
rejecting the filesystem, the program instead crashed. I figured out
|
||||||
|
that zeroing the superblock was enough to trigger this:
|
||||||
|
|
||||||
|
# dd if=/dev/zero of=/dev/sda bs=1024k count=1
|
||||||
|
# xfs_copy /dev/sda /dev/sdb
|
||||||
|
Floating point exception
|
||||||
|
|
||||||
|
The exact crash happens in this line from libxfs_getbuf_flags, which is
|
||||||
|
called from the main() routine of xfs_copy:
|
||||||
|
|
||||||
|
if (btp == btp->bt_mount->m_ddev_targp) {
|
||||||
|
(*bpp)->b_pag = xfs_perag_get(btp->bt_mount,
|
||||||
|
xfs_daddr_to_agno(btp->bt_mount, blkno));
|
||||||
|
|
||||||
|
The problem here is that the uncached read filled the incore superblock
|
||||||
|
with zeroes, which means mbuf.sb_agblocks is zero. This causes a
|
||||||
|
division by zero in xfs_daddr_to_agno, thereby crashing the program.
|
||||||
|
|
||||||
|
In commit f8b581d6, we made it so that xfs_buf structures contain a
|
||||||
|
passive reference to the associated perag structure. That commit
|
||||||
|
assumes that no program would try a cached buffer read until the buffer
|
||||||
|
cache is fully set up, which is true throughout xfsprogs... except for
|
||||||
|
the beginning of xfs_copy. For whatever reason, it attempts an uncached
|
||||||
|
read of the superblock to figure out the real superblock size, then
|
||||||
|
performs a *cached* read with the proper buffer length and verifier.
|
||||||
|
The cached read crashes the program.
|
||||||
|
|
||||||
|
Fix the problem by changing the (second) cached read into an uncached read.
|
||||||
|
|
||||||
|
Fixes: f8b581d6 ("libxfs: actually make buffers track the per-ag structures")
|
||||||
|
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
|
||||||
|
Reviewed-by: Dave Chinner <dchinner@redhat.com>
|
||||||
|
Reviewed-by: Christoph Hellwig <hch@lst.de>
|
||||||
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
||||||
|
---
|
||||||
|
copy/xfs_copy.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
|
||||||
|
index 41f594bd..79f65946 100644
|
||||||
|
--- a/copy/xfs_copy.c
|
||||||
|
+++ b/copy/xfs_copy.c
|
||||||
|
@@ -748,7 +748,7 @@ main(int argc, char **argv)
|
||||||
|
/* Do it again, now with proper length and verifier */
|
||||||
|
libxfs_buf_relse(sbp);
|
||||||
|
|
||||||
|
- error = -libxfs_buf_read(mbuf.m_ddev_targp, XFS_SB_DADDR,
|
||||||
|
+ error = -libxfs_buf_read_uncached(mbuf.m_ddev_targp, XFS_SB_DADDR,
|
||||||
|
1 << (sb->sb_sectlog - BBSHIFT), 0, &sbp,
|
||||||
|
&xfs_sb_buf_ops);
|
||||||
|
if (error) {
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: xfsprogs
|
Name: xfsprogs
|
||||||
Version: 5.14.1
|
Version: 5.14.1
|
||||||
Release: 13
|
Release: 14
|
||||||
Summary: Administration and debugging tools for the XFS file system
|
Summary: Administration and debugging tools for the XFS file system
|
||||||
License: GPL+ and LGPLv2+
|
License: GPL+ and LGPLv2+
|
||||||
URL: https://xfs.wiki.kernel.org
|
URL: https://xfs.wiki.kernel.org
|
||||||
@ -29,6 +29,7 @@ Patch7: 0007-libxcmd-add-return-value-check-for-dynamic-memory-fu.patch
|
|||||||
Patch8: 0008-xfs_repair-fix-the-problem-of-repair-failure-caused-.patch
|
Patch8: 0008-xfs_repair-fix-the-problem-of-repair-failure-caused-.patch
|
||||||
Patch9: 0009-mkfs.xfs-fix-segmentation-fault-caused-by-accessing-.patch
|
Patch9: 0009-mkfs.xfs-fix-segmentation-fault-caused-by-accessing-.patch
|
||||||
Patch10: 0010-xfs_repair-fix-warn-in-xfs_buf_find-when-growfs-fails.patch
|
Patch10: 0010-xfs_repair-fix-warn-in-xfs_buf_find-when-growfs-fails.patch
|
||||||
|
Patch11: 0011-xfs_copy-don-t-use-cached-buffer-reads-until-after-l.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
xfsprogs are the userspace utilities that manage XFS filesystems.
|
xfsprogs are the userspace utilities that manage XFS filesystems.
|
||||||
@ -112,6 +113,9 @@ rm -rf %{buildroot}%{_datadir}/doc/xfsprogs/
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Nov 3 2023 wuguanghao <wuguanghao3@huawei.com> - 5.14.1-14
|
||||||
|
- xfs_copy: don't use cached buffer reads until after libxfs_mount
|
||||||
|
|
||||||
* Tue Sep 12 2023 wuguanghao <wuguanghao3@huawei.com> - 5.14.1-13
|
* Tue Sep 12 2023 wuguanghao <wuguanghao3@huawei.com> - 5.14.1-13
|
||||||
- xfs_repair: fix warn in xfs_buf_find when growfs fails
|
- xfs_repair: fix warn in xfs_buf_find when growfs fails
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user