xfstests: hexdump and CVE-2022-0847
cover xfstests: hexdump and CVE-2022-0847
This patchset contains 2 patches:
[PATCH 1/2] xfstests: replace hexdump with od command
[PATCH 2/2] fstests: test dirty pipe vulnerability issue of CVE-2022-0847
I've sent the V2 [2/2] last week[1], but due to the [2/2] hasn't been merged and the [1/2] will affect [2/2]. So I send these two patches in one patchset this time. Just please note, the [2/2] is the last version.
[1]
https://lore.kernel.org/fstests/[email protected]/
Thanks,
Zorro
PATCH 1/2 xfstests: replace hexdump with od command
The "od" is one of the most fundamental commands in GNU/Linux and most Unix-like systems. So we nearly always can count on it, don't need to check if it's installed.
The "hexdump" isn't such fundamental as "od", some systems don't install it by default. And as "od" nearly can replace all functions of "hexdump", so let's use an unified command "od" to do the hexdump job in fstests cases.
---
Hi,
As Dave and Darrick suggested, I did this change, I've tested most of cases, except f2fs/001 and ceph/002, but I think they're good. And I used "od" command directly in generic/404 and generic/042 for their special reason.
Thanks,
Zorro
common/rc | 12 + tests/ceph/002 | 2 +- tests/ceph/002.out | 8 +- tests/f2fs/001 | 4 +- tests/f2fs/001.out | 16 +- tests/generic/029 | 12 +- tests/generic/029.out | 68 +-- tests/generic/030 | 12 +- tests/generic/030.out | 48 +- tests/generic/031 | 4 +- tests/generic/031.out | 16 +- tests/generic/032 | 2 +- tests/generic/032.out | 4 +- tests/generic/033 | 2 +- tests/generic/033.out | 4 +- tests/generic/042 | 4 +- tests/generic/086 | 2 +- tests/generic/086.out | 14 +- tests/generic/404 | 2 +- tests/generic/404.out | 996 +++++++++++++++++++++--------------------- tests/generic/536 | 4 +- tests/generic/567 | 4 +- tests/generic/567.out | 16 +- tests/generic/612 | 4 +- tests/generic/612.out | 8 +- tests/generic/639 | 2 +- tests/generic/639.out | 4 +- 27 files changed, 643 insertions(+), 631 deletions(-)
common/rc +12 -0
@@ -4856,6 +4856,18 @@ _require_kernel_config() _has_kernel_config $1 || _notrun "Installed kernel not built with $1" } +_hexdump() +{ + # Hex format address and data output + od -Ax -t x1z $* +} + +# Disable hexdump, turn to use "od" command in _hexdump +hexdump() +{ + _fail "Use _hexdump(), please!" +} + init_rc ################################################################################
tests/ceph/002 +1 -1
@@ -59,7 +59,7 @@ $XFS_IO_PROG -c "truncate 0" $dest >> $seqres.full 2>&1 # copy the whole file over $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 3)) $file" "$dest" -hexdump $dest +_hexdump $dest #success, all done status=0
tests/ceph/002.out +4 -4
@@ -1,8 +1,8 @@ QA output created by 002 -0000000 6161 6161 6161 6161 6161 6161 6161 6161 +000000 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 >aaaaaaaaaaaaaaaa< * -0400000 6262 6262 6262 6262 6262 6262 6262 6262 +400000 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 >bbbbbbbbbbbbbbbb< * -0800000 6363 6363 6363 6363 6363 6363 6363 6363 +800000 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 >cccccccccccccccc< * -0c00000 +c000000
tests/f2fs/001 +2 -2
@@ -45,9 +45,9 @@ $XFS_IO_PROG -c "truncate 96" -c "pwrite -S 0x58 8192 4096" $testfile 2>&1 \ | _filter_xfs_io_error echo "==== check data contents ====" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount -hexdump -C $testfile +_hexdump $testfile rm $testfile rm $dummyfile
tests/f2fs/001.out +8 -8
@@ -7,15 +7,15 @@ fallocate: No space left on device ==== change i_size & write data ==== pwrite: No space left on device ==== check data contents ==== -00000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 |XXXXXXXXXXXXXXXX| +000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 >XXXXXXXXXXXXXXXX< * -00000020 58 58 58 58 58 58 58 58 00 00 00 00 00 00 00 00 |XXXXXXXX........| -00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000020 58 58 58 58 58 58 58 58 00 00 00 00 00 00 00 00 >XXXXXXXX........< +000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -00000060 -00000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 |XXXXXXXXXXXXXXXX| +000060 +000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 >XXXXXXXXXXXXXXXX< * -00000020 58 58 58 58 58 58 58 58 00 00 00 00 00 00 00 00 |XXXXXXXX........| -00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000020 58 58 58 58 58 58 58 58 00 00 00 00 00 00 00 00 >XXXXXXXX........< +000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -00000060 +000060
tests/generic/029 +6 -6
@@ -39,10 +39,10 @@ $XFS_IO_PROG -t -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile rm -f $testfile sync
@@ -64,10 +64,10 @@ $XFS_IO_PROG -t -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile # third case is the same as second case, just with non-1k aligned offsets and # sizes.
@@ -84,10 +84,10 @@ $XFS_IO_PROG -t -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile status=0 exit
tests/generic/029.out +34 -34
98 lines not on this page · raw message
tests/generic/030 +6 -6
@@ -44,10 +44,10 @@ $XFS_IO_PROG -t -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile rm -f $testfile sync
@@ -73,10 +73,10 @@ $XFS_IO_PROG -t -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile # third case is the same as the first, but this time on unaligned byte # boundaries rather than block boundaries. This mimics the exact mmap write
@@ -109,10 +109,10 @@ $XFS_IO_PROG -t -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile status=0 exit
tests/generic/030.out +24 -24
76 lines not on this page · raw message
tests/generic/031 +2 -2
@@ -34,10 +34,10 @@ $XFS_IO_PROG -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile status=0 exit
tests/generic/031.out +8 -8
@@ -4,16 +4,16 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 63394/63394 bytes at offset 133228 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) ==== Pre-Remount === -00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -0001f860 00 00 00 00 00 00 00 00 00 00 00 00 cd cd cd cd |................| -0001f870 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd |................| +01f860 00 00 00 00 00 00 00 00 00 00 00 00 cd cd cd cd >................< +01f870 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd >................< * -0002fdc0 +02fdc0 ==== Post-Remount == -00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -0001f860 00 00 00 00 00 00 00 00 00 00 00 00 cd cd cd cd |................| -0001f870 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd |................| +01f860 00 00 00 00 00 00 00 00 00 00 00 00 cd cd cd cd >................< +01f870 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd >................< * -0002fdc0 +02fdc0
tests/generic/032 +1 -1
@@ -85,7 +85,7 @@ wait # clear page cache and dump the file _scratch_cycle_mount -hexdump $SCRATCH_MNT/file +_hexdump $SCRATCH_MNT/file status=0 exit
tests/generic/032.out +2 -2
@@ -1,5 +1,5 @@ QA output created by 032 100 iterations -0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd +000000 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd >................< * -0100000 +100000
tests/generic/033 +1 -1
@@ -48,7 +48,7 @@ for i in $(seq 4096 8192 $endoff); do done _scratch_cycle_mount -hexdump $file +_hexdump $file status=0 exit
tests/generic/033.out +2 -2
@@ -1,4 +1,4 @@ QA output created by 033 -0000000 0000 0000 0000 0000 0000 0000 0000 0000 +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -0010000 +010000
tests/generic/042 +2 -2
@@ -57,9 +57,9 @@ _crashtest() # We should /never/ see 0xCD in the file, because we wrote that pattern # to the filesystem image to expose stale data. - if hexdump -v -e '/1 "%02X "' $file | grep -q "CD"; then + if od -An -tx1 -v $file | grep -q "CD"; then echo "Saw stale data!!!" - hexdump $file + _hexdump $file fi $UMOUNT_PROG $mnt
tests/generic/086 +1 -1
@@ -49,7 +49,7 @@ echo 3 > /proc/sys/vm/drop_caches $XFS_IO_PROG -c "pwrite -S 0xdd 67584 2048" $test_file >> $seqres.full 2>&1 # On a faulty ext4 oxbb data will be missing, overwritten by zeroes. -hexdump -C $test_file +_hexdump $test_file # success, all done status=0
tests/generic/086.out +7 -7
@@ -1,14 +1,14 @@ QA output created by 086 -00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -00001000 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa |................| +001000 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa >................< * -00001800 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +001800 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -00010000 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb |................| +010000 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >................< * -00010800 dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd |................| +010800 dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd >................< * -00011000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +011000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -00020000 +020000
tests/generic/404 +1 -1
@@ -110,7 +110,7 @@ for (( block=3; block<=500; block++ )); do # or blocks are in correct order, this commit: # 2b3864b32403 ("ext4: do not polute the extents cache while shifting extents") # - md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` + md5=`od -An -c $testfile | md5sum` printf "#%d %s\n" "$block" "$md5" done
tests/generic/404.out +498 -498
997 lines not on this page · raw message
tests/generic/536 +2 -2
@@ -47,9 +47,9 @@ _scratch_shutdown -f # second file should also be zero filled. _scratch_cycle_mount echo file.1 | tee -a $seqres.full -hexdump $SCRATCH_MNT/file.1 | tee -a $seqres.full | grep ab +_hexdump $SCRATCH_MNT/file.1 | tee -a $seqres.full | grep ab echo file.2 | tee -a $seqres.full -hexdump $SCRATCH_MNT/file.2 | tee -a $seqres.full | grep ab +_hexdump $SCRATCH_MNT/file.2 | tee -a $seqres.full | grep ab status=0 exit
tests/generic/567 +2 -2
@@ -39,10 +39,10 @@ $XFS_IO_PROG -t -f \ $testfile | _filter_xfs_io echo "==== Pre-Remount ===" -hexdump -C $testfile +_hexdump $testfile _scratch_cycle_mount echo "==== Post-Remount ==" -hexdump -C $testfile +_hexdump $testfile status=0 exit
tests/generic/567.out +8 -8
@@ -2,18 +2,18 @@ QA output created by 567 wrote 12288/12288 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) ==== Pre-Remount === -00000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 |XXXXXXXXXXXXXXXX| +000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 >XXXXXXXXXXXXXXXX< * -00000800 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 |YYYYYYYYYYYYYYYY| +000800 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 >YYYYYYYYYYYYYYYY< * -00002800 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 |XXXXXXXXXXXXXXXX| +002800 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 >XXXXXXXXXXXXXXXX< * -00003000 +003000 ==== Post-Remount == -00000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 |XXXXXXXXXXXXXXXX| +000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 >XXXXXXXXXXXXXXXX< * -00000800 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 |YYYYYYYYYYYYYYYY| +000800 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 >YYYYYYYYYYYYYYYY< * -00002800 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 |XXXXXXXXXXXXXXXX| +002800 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 >XXXXXXXXXXXXXXXX< * -00003000 +003000
tests/generic/612 +2 -2
@@ -47,7 +47,7 @@ echo "Reflink copy from b to a" cp --reflink=always $DIR/b $DIR/a echo "Contents of b" -hexdump -C $DIR/b +_hexdump $DIR/b # Cycle mount to get stuff out of cache _test_cycle_mount
@@ -62,7 +62,7 @@ $XFS_IO_PROG -c "pwrite -S 0xa 0k -b 4k 4k" \ $XFS_IO_PROG -c fsync $DIR/a echo "Contents of b now:" -hexdump -C $DIR/b +_hexdump $DIR/b # success, all done status=0
tests/generic/612.out +4 -4
@@ -4,15 +4,15 @@ wrote 2097152/2097152 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Reflink copy from b to a Contents of b -00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -00200000 +200000 Write to a wrote 4096/4096 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 1048576/1048576 bytes at offset 4096 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Contents of b now: -00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< * -00200000 +200000
tests/generic/639 +1 -1
@@ -33,7 +33,7 @@ $XFS_IO_PROG -c "pwrite -q 32 32" $testfile # dump what we think is in there echo "The result should be 64 bytes filled with 0xcd:" -hexdump -C $testfile +_hexdump $testfile status=0 exit
tests/generic/639.out +2 -2
@@ -1,5 +1,5 @@ QA output created by 639 The result should be 64 bytes filled with 0xcd: -00000000 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd |................| +000000 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd >................< * -00000040 +000040
Signature · 1 line
2.31.1
Re: [PATCH 1/2] xfstests: replace hexdump with od command
Quoted 10 lines · Zorro Lang
The "od" is one of the most fundamental commands in GNU/Linux and most Unix-like systems. So we nearly always can count on it, don't need to check if it's installed.
The "hexdump" isn't such fundamental as "od", some systems don't install it by default. And as "od" nearly can replace all functions of "hexdump", so let's use an unified command "od" to do the hexdump job in fstests cases.
Signed-off-by Zorro Lang <[email protected]>
Looks good.
Quoted 7 lines
---
Hi,
As Dave and Darrick suggested, I did this change, I've tested most of cases, except f2fs/001 and ceph/002, but I think they're good. And I used "od" command directly in generic/404 and generic/042 for their special reason.
That generic/404 usage is ... strange. Why record md5sums of the encoded hexdump output of the file when you can just run md5sum on the file directly and get the same information? i.e.
tests/generic/404 for (( block=3; block<=500; block++ )); do · line 114
Quoted 11 lines
tests/generic/404 +1
-1@@ -110,7 +110,7 @@ for (( block=3; block<=500; block++ )); do # or blocks are in correct order, this commit: # 2b3864b32403 ("ext4: do not polute the extents cache while shifting extents") # - md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` + md5=`od -An -c $testfile | md5sum` printf "#%d %s\n" "$block" "$md5"
Why isn't this just:
- md5=hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum
- printf "#%d %s\n" "$block" "$md5"
+ echo -n "#$block "
+ md5sum $testfile | _filter_test_dir
Seperate patch, perhaps?
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 1/2] xfstests: replace hexdump with od command
Quoted 42 lines · Dave Chinner
Quoted 10 lines · Zorro Lang
The "od" is one of the most fundamental commands in GNU/Linux and most Unix-like systems. So we nearly always can count on it, don't need to check if it's installed.
The "hexdump" isn't such fundamental as "od", some systems don't install it by default. And as "od" nearly can replace all functions of "hexdump", so let's use an unified command "od" to do the hexdump job in fstests cases.
Signed-off-by Zorro Lang <[email protected]>Looks good.
Reviewed-by Dave Chinner <[email protected]>Quoted 7 lines
---
Hi,
As Dave and Darrick suggested, I did this change, I've tested most of cases, except f2fs/001 and ceph/002, but I think they're good. And I used "od" command directly in generic/404 and generic/042 for their special reason.
That generic/404 usage is ... strange. Why record md5sums of the encoded hexdump output of the file when you can just run md5sum on the file directly and get the same information? i.e.
tests/generic/404 for (( block=3; block<=500; block++ )); do · line 114
Quoted 11 lines
tests/generic/404 +1
-1@@ -110,7 +110,7 @@ for (( block=3; block<=500; block++ )); do # or blocks are in correct order, this commit: # 2b3864b32403 ("ext4: do not polute the extents cache while shifting extents") # - md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` + md5=`od -An -c $testfile | md5sum` printf "#%d %s\n" "$block" "$md5"Why isn't this just:
Review
Quoted 4 lines
(quoted diff) +2
-2- md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` - printf "#%d %s\n" "$block" "$md5" + echo -n "#$block " + md5sum $testfile | _filter_test_dir
Yes, I thought about that too, but I can't be sure about it, so tried to keep the logic of original code. If the original author doesn't have some special reason, I'd like to change it as this way (cc [email protected]).
And for the generic/042:
- if hexdump -v -e '/1 "%02X "' $file | grep -q "CD"; then
+ if od -An -tx1 -v $file | grep -q "CD"; then
I don't know what that "-v" option is needed (cc Darrick). I thought it might just waste the time of grep running ?
Quoted 2 lines
Seperate patch, perhaps?
Sure, if no one object that, I'll change them in separated patch.
Thanks,
Zorro
Quoted 8 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 1/2] xfstests: replace hexdump with od command
Quoted 56 lines · Zorro Lang
Quoted 42 lines · Dave Chinner
Quoted 10 lines · Zorro Lang
The "od" is one of the most fundamental commands in GNU/Linux and most Unix-like systems. So we nearly always can count on it, don't need to check if it's installed.
The "hexdump" isn't such fundamental as "od", some systems don't install it by default. And as "od" nearly can replace all functions of "hexdump", so let's use an unified command "od" to do the hexdump job in fstests cases.
Signed-off-by Zorro Lang <[email protected]>Looks good.
Reviewed-by Dave Chinner <[email protected]>Quoted 7 lines
---
Hi,
As Dave and Darrick suggested, I did this change, I've tested most of cases, except f2fs/001 and ceph/002, but I think they're good. And I used "od" command directly in generic/404 and generic/042 for their special reason.
That generic/404 usage is ... strange. Why record md5sums of the encoded hexdump output of the file when you can just run md5sum on the file directly and get the same information? i.e.
tests/generic/404 for (( block=3; block<=500; block++ )); do · line 114
Quoted 11 lines
tests/generic/404 +1
-1@@ -110,7 +110,7 @@ for (( block=3; block<=500; block++ )); do # or blocks are in correct order, this commit: # 2b3864b32403 ("ext4: do not polute the extents cache while shifting extents") # - md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` + md5=`od -An -c $testfile | md5sum` printf "#%d %s\n" "$block" "$md5"Why isn't this just:
Review
Quoted 4 lines
(quoted diff) +2
-2- md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` - printf "#%d %s\n" "$block" "$md5" + echo -n "#$block " + md5sum $testfile | _filter_test_dirYes, I thought about that too, but I can't be sure about it, so tried to keep the logic of original code. If the original author doesn't have some special reason, I'd like to change it as this way (cc [email protected]).
And for the generic/042:
tests/generic/042 +1
-1- if hexdump -v -e '/1 "%02X "' $file | grep -q "CD"; then + if od -An -tx1 -v $file | grep -q "CD"; then
Quoted 2 lines
I don't know what that "-v" option is needed (cc Darrick). I thought it might just waste the time of grep running ?
Probably. I probably put that in there for debugging purposes and then frogot to take it out.
--D
Quoted 17 lines
Quoted 2 lines
Seperate patch, perhaps?
Sure, if no one object that, I'll change them in separated patch.
Thanks,
ZorroQuoted 8 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 1/2] xfstests: replace hexdump with od command
Quoted 57 lines · Darrick J. Wong
Quoted 56 lines · Zorro Lang
Quoted 42 lines · Dave Chinner
Quoted 10 lines · Zorro Lang
The "od" is one of the most fundamental commands in GNU/Linux and most Unix-like systems. So we nearly always can count on it, don't need to check if it's installed.
The "hexdump" isn't such fundamental as "od", some systems don't install it by default. And as "od" nearly can replace all functions of "hexdump", so let's use an unified command "od" to do the hexdump job in fstests cases.
Signed-off-by Zorro Lang <[email protected]>Looks good.
Reviewed-by Dave Chinner <[email protected]>Quoted 7 lines
---
Hi,
As Dave and Darrick suggested, I did this change, I've tested most of cases, except f2fs/001 and ceph/002, but I think they're good. And I used "od" command directly in generic/404 and generic/042 for their special reason.
That generic/404 usage is ... strange. Why record md5sums of the encoded hexdump output of the file when you can just run md5sum on the file directly and get the same information? i.e.
tests/generic/404 for (( block=3; block<=500; block++ )); do · line 114
Quoted 11 lines
tests/generic/404 +1
-1@@ -110,7 +110,7 @@ for (( block=3; block<=500; block++ )); do # or blocks are in correct order, this commit: # 2b3864b32403 ("ext4: do not polute the extents cache while shifting extents") # - md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` + md5=`od -An -c $testfile | md5sum` printf "#%d %s\n" "$block" "$md5"Why isn't this just:
Review
Quoted 4 lines
(quoted diff) +2
-2- md5=`hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum` - printf "#%d %s\n" "$block" "$md5" + echo -n "#$block " + md5sum $testfile | _filter_test_dirYes, I thought about that too, but I can't be sure about it, so tried to keep the logic of original code. If the original author doesn't have some special reason, I'd like to change it as this way (cc [email protected]).
And for the generic/042:
tests/generic/042 +1
-1- if hexdump -v -e '/1 "%02X "' $file | grep -q "CD"; then + if od -An -tx1 -v $file | grep -q "CD"; then
Quoted 5 lines
Quoted 2 lines
I don't know what that "-v" option is needed (cc Darrick). I thought it might just waste the time of grep running ?
Probably. I probably put that in there for debugging purposes and then frogot to take it out.
Thanks Darrick, I'll remove it in V2 patch.
I tried to ask [email protected], but that email can't be reached. So I'll change g/404 as we talked.
Quoted 21 lines
--D
Quoted 17 lines
Quoted 2 lines
Seperate patch, perhaps?
Sure, if no one object that, I'll change them in separated patch.
Thanks,
ZorroQuoted 8 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH 2/2 fstests: test dirty pipe vulnerability issue of CVE-2022-0847
In reply to Zorro LangTest for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an uninitialized "pipe_buffer.flags" variable. The bug cause a file can be overwritten even if a user/process is not permitted to write it. It's fixed by 9d2231c5d74e ("lib/iov_iter: initialize "flags" in new pipe_buffer").
--- .gitignore | 1 + src/Makefile | 2 +- src/splice2pipe.c | 158 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/999 | 54 +++++++++++++++ tests/generic/999.out | 9 +++ 5 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 src/splice2pipe.c create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out
.gitignore +1 -0
@@ -125,6 +125,7 @@ tags /src/runas /src/seek_copy_test /src/seek_sanity_test +/src/splice2pipe /src/splice-test /src/stale_handle /src/stat_test
src/Makefile +1 -1
@@ -31,7 +31,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ dio-invalidate-cache stat_test t_encrypted_d_revalidate \ attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \ fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \ - detached_mounts_propagation ext4_resize t_readdir_3 + detached_mounts_propagation ext4_resize t_readdir_3 splice2pipe EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \ btrfs_crc32c_forged_name.py
src/splice2pipe.c new file +158 -0
158 lines not on this page · raw message
tests/generic/999 new file +54 -0
54 lines not on this page · raw message
tests/generic/999.out new file +9 -0
@@ -0,0 +1,9 @@ +QA output created by 999 +Test privileged user: +000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +001000 +Test unprivileged user: +000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +001000
Signature · 1 line
2.31.1
Re: [PATCH 2/2] fstests: test dirty pipe vulnerability issue of CVE-2022-0847
Quoted 15 lines · Zorro Lang
tests/generic/999 new file +9
-0@@ -0,0 +1,54 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 999 +# +# Test for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an +# uninitialized "pipe_buffer.flags" variable, which fixed by: +# 9d2231c5d74e ("lib/iov_iter: initialize "flags" in new pipe_buffer")
tests/generic/999 line 19
Quoted 10 lines
tests/generic/999 new file +10
-0+# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{ + cd / + rm -f $tmp.* + rm -f $TEST_DIR/testfile.$seq +}
Just leave the test file lying around so this can use the default cleanup method. The test device is supposed to gather random cruft as tests run....
tests/generic/999 line 28
Quoted 9 lines
tests/generic/999 new file +9
-0+ +# real QA test starts here +_supported_fs generic +_require_test +_require_user +_require_chmod +_require_test_program "splice2pipe" + +localfile=$TEST_DIR/testfile.$seq
.... and remove the file here as part of test setup with:
rm -f $localfile
Otherwise looks fine.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 2/2] fstests: test dirty pipe vulnerability issue of CVE-2022-0847
Quoted 22 lines · Dave Chinner
Quoted 21 lines · Zorro Lang
tests/generic/999 new file +15
-0@@ -0,0 +1,54 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 999 +# +# Test for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an +# uninitialized "pipe_buffer.flags" variable, which fixed by: +# 9d2231c5d74e ("lib/iov_iter: initialize "flags" in new pipe_buffer") +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{
Quoted 8 lines
tests/generic/999 line 19
Quoted 4 lines
tests/generic/999 new file +4
-0+ cd / + rm -f $tmp.* + rm -f $TEST_DIR/testfile.$seq +}Just leave the test file lying around so this can use the default cleanup method. The test device is supposed to gather random cruft as tests run....
Got that, I'll keep this file, and turn to use default _cleanup.
Quoted 13 lines
tests/generic/999 line 28
Quoted 10 lines
tests/generic/999 new file +9
-0+ +# real QA test starts here +_supported_fs generic +_require_test +_require_user +_require_chmod +_require_test_program "splice2pipe" + +localfile=$TEST_DIR/testfile.$seq.... and remove the file here as part of test setup with:
Quoted 1 line
rm -f $localfile
Just curious, I've used xfs_io "-t" option to truncate $localfile before testing:
$XFS_IO_PROG -f -t -c "pwrite 0 4k -S 0xff" $localfile
Can that instead of the "rm -f $localfile" ?
(As both patches need to change, I'd like to change the 1st patch's g/404 in next version patch together, if no objection)
Thanks,
Zorro
Quoted 10 lines
Otherwise looks fine.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 2/2] fstests: test dirty pipe vulnerability issue of CVE-2022-0847
Quoted 47 lines · Zorro Lang
Quoted 22 lines · Dave Chinner
Quoted 21 lines · Zorro Lang
tests/generic/999 new file +15
-0@@ -0,0 +1,54 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 999 +# +# Test for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an +# uninitialized "pipe_buffer.flags" variable, which fixed by: +# 9d2231c5d74e ("lib/iov_iter: initialize "flags" in new pipe_buffer") +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{Quoted 8 lines
tests/generic/999 line 19
Quoted 4 lines
tests/generic/999 new file +4
-0+ cd / + rm -f $tmp.* + rm -f $TEST_DIR/testfile.$seq +}Just leave the test file lying around so this can use the default cleanup method. The test device is supposed to gather random cruft as tests run....
Got that, I'll keep this file, and turn to use default
_cleanup.Quoted 13 lines
tests/generic/999 line 28
Quoted 10 lines
tests/generic/999 new file +9
-0+ +# real QA test starts here +_supported_fs generic +_require_test +_require_user +_require_chmod +_require_test_program "splice2pipe" + +localfile=$TEST_DIR/testfile.$seq.... and remove the file here as part of test setup with:
Quoted 6 lines
Quoted 1 line
rm -f $localfile
Just curious, I've used
xfs_io"-t" option to truncate $localfile before testing:
$XFS_IO_PROG -f -t -c "pwrite 0 4k -S0xff" $localfileCan that instead of the "rm -f $localfile" ?
Open-and-truncate isn't safe here because some other (buggy) test might run 'mkfifo $TEST_DIR/testfile.XXX' and now opening the pipe will hang fstests. It's ok for the scratch fs because you have to mkfs it, but as Dave said, the test fs slowly accumulates cruft over time.
--D
Quoted 17 lines
(As both patches need to change, I'd like to change the 1st patch's g/404 in next version patch together, if no objection)
Thanks,
ZorroQuoted 10 lines
Otherwise looks fine.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 2/2] fstests: test dirty pipe vulnerability issue of CVE-2022-0847
Quoted 53 lines · Darrick J. Wong
Quoted 52 lines · Zorro Lang
Quoted 22 lines · Dave Chinner
Quoted 21 lines · Zorro Lang
tests/generic/999 new file +15
-0@@ -0,0 +1,54 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 999 +# +# Test for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an +# uninitialized "pipe_buffer.flags" variable, which fixed by: +# 9d2231c5d74e ("lib/iov_iter: initialize "flags" in new pipe_buffer") +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{Quoted 8 lines
tests/generic/999 line 19
Quoted 4 lines
tests/generic/999 new file +4
-0+ cd / + rm -f $tmp.* + rm -f $TEST_DIR/testfile.$seq +}Just leave the test file lying around so this can use the default cleanup method. The test device is supposed to gather random cruft as tests run....
Got that, I'll keep this file, and turn to use default
_cleanup.Quoted 13 lines
tests/generic/999 line 28
Quoted 10 lines
tests/generic/999 new file +9
-0+ +# real QA test starts here +_supported_fs generic +_require_test +_require_user +_require_chmod +_require_test_program "splice2pipe" + +localfile=$TEST_DIR/testfile.$seq.... and remove the file here as part of test setup with:
Quoted 1 line
rm -f $localfile
Just curious, I've used
xfs_io"-t" option to truncate $localfile before testing:
$XFS_IO_PROG -f -t -c "pwrite 0 4k -S0xff" $localfile
Quoted 6 lines
Quoted 1 line
Can that instead of the "rm -f $localfile" ?
Open-and-truncate isn't safe here because some other (buggy) test might run 'mkfifo $TEST_DIR/testfile.XXX' and now opening the pipe will hang fstests. It's ok for the scratch fs because you have to mkfs it, but as Dave said, the test fs slowly accumulates cruft over time.
Make sense, Thanks! I'll change that.
Thanks,
Zorro
Quoted 21 lines
--D
Quoted 17 lines
(As both patches need to change, I'd like to change the 1st patch's g/404 in next version patch together, if no objection)
Thanks,
ZorroQuoted 10 lines
Otherwise looks fine.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]