ext4: test for illegal memory access caused by quota index information error
PATCH 1/1 ext4: test for illegal memory access caused by quota index information error
The quota index information in the image is tampered, causing illegal memory access.
It is a regression test for Kernel commit 9bf3d2033129 quota: check block number when reading the block in quota file and commit d0e36a62bd4c
quota: correct error number in free_dqentry().
--- tests/ext4/054 | 36 ++++++++++++++++++++++++++++++++++++ tests/ext4/054.out | 1 + 2 files changed, 37 insertions(+) create mode 100755 tests/ext4/054 create mode 100644 tests/ext4/054.out
tests/ext4/054 new file +36 -0
@@ -0,0 +1,36 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Huawei. All Rights Reserved. +# +# FS QA Test 054 +# +# Regression test for kernel +# commit 9bf3d2033129 quota: check block number when reading the block in quota file +# commit d0e36a62bd4c quota: correct error number in free_dqentry() +# +# The test is based on a testcase from Zhang Yi <[email protected]>. +# +. ./common/preamble +_begin_fstest auto + +# real QA test starts here + +# Modify as appropriate. +_require_scratch +_supported_fs ext4 +_require_user fsgqa +_require_user fsgqa2 + +_scratch_mkfs "-F -O quota -b 1024" > $seqres.full 2>&1 +debugfs -w -R "zap_block -o 0 -l 1 -p 6 -f <3> 1" $SCRATCH_DEV >> $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 +chown fsgqa:fsgqa $SCRATCH_MNT >> $seqres.full 2>&1 +touch $SCRATCH_MNT/foo >> $seqres.full 2>&1 +rm -f $SCRATCH_MNT/foo +chown fsgqa2:fsgqa2 $SCRATCH_MNT >> $seqres.full 2>&1 + +umount $SCRATCH_MNT + +# success, all done +status=0 +exit
tests/ext4/054.out new file +1 -0
@@ -0,0 +1 @@ +QA output created by 054
Signature · 1 line
2.13.6
Quoted 20 lines · Sun Ke
The quota index information in the image is tampered, causing illegal memory access.
It is a regression test for Kernel commit9bf3d2033129quota: check block number when reading the block in quota file and commitd0e36a62bd4c
quota: correct error number infree_dqentry().Signed-off-by Sun Ke <[email protected]>--- tests/ext4/054 | 36 ++++++++++++++++++++++++++++++++++++ tests/ext4/054.out | 1 + 2 files changed, 37 insertions(+) create mode 100755 tests/ext4/054 create mode 100644 tests/ext4/054.outtests/ext4/054 new file +0
-0
tests/ext4/054 line 9
Quoted 9 lines
tests/ext4/054 new file +9
-0@@ -0,0 +1,36 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Huawei. All Rights Reserved. +# +# FS QA Test 054 +# +# Regression test for kernel +# commit 9bf3d2033129 quota: check block number when reading the block in quota file +# commit d0e36a62bd4c quota: correct error number in free_dqentry()
Better to describe the test in test description as well, e.g. what's the bug and summarise how we're going to test it.
tests/ext4/054 line 14
Quoted 5 lines
tests/ext4/054 new file +5
-0+# +# The test is based on a testcase from Zhang Yi <[email protected]>. +# +. ./common/preamble +_begin_fstest auto
In 'quota' group as well
tests/ext4/054 line 22
Quoted 8 lines
tests/ext4/054 new file +8
-0+ +# real QA test starts here + +# Modify as appropriate. +_require_scratch +_supported_fs ext4 +_require_user fsgqa +_require_user fsgqa2
_require_command "$DEBUGFS_PROG" debugfs
and use $DEBUGFS_PRG in the test.
tests/ext4/054 line 24
Quoted 2 lines
tests/ext4/054 new file +2
-0+ +_scratch_mkfs "-F -O quota -b 1024" > $seqres.full 2>&1
Is 1k block size a required condition to reproduce the bug? Or the following debugfs command requires 1k fs?
tests/ext4/054 line 25
Quoted 1 line
tests/ext4/054 new file +1
-0+debugfs -w -R "zap_block -o 0 -l 1 -p 6 -f <3> 1" $SCRATCH_DEV >> $seqres.full 2>&1
Some comments are welcomed to describe the detailed test steps, e.g. explain what's the purpose of this debugfs command.
tests/ext4/054 line 30
Quoted 5 lines
tests/ext4/054 new file +5
-0+_scratch_mount >> $seqres.full 2>&1 +chown fsgqa:fsgqa $SCRATCH_MNT >> $seqres.full 2>&1 +touch $SCRATCH_MNT/foo >> $seqres.full 2>&1 +rm -f $SCRATCH_MNT/foo +chown fsgqa2:fsgqa2 $SCRATCH_MNT >> $seqres.full 2>&1
And why we need to chown fsgqa:fsgqa first and rm the file and chown to fsgqa2 later.
tests/ext4/054 line 32
Quoted 2 lines
tests/ext4/054 new file +2
-0+ +umount $SCRATCH_MNT
Is this required to trigger the bug? If not, this could be removed, SCRATCH_DEV will be umounted after each test.
tests/ext4/054.out line 1
Quoted 11 lines
tests/ext4/054 new file +4
-0+ +# success, all done +status=0 +exittests/ext4/054.out new file +1
-0@@ -0,0 +1 @@ +QA output created by 054
Need "Silence is golden" to indicate this test doesn't print any output.
Thanks,
Eryu
Quoted 2 lines
Signature · 1 line
2.13.6
Quoted 53 lines · Eryu Guan
Quoted 20 lines · Sun Ke
The quota index information in the image is tampered, causing illegal memory access.
It is a regression test for Kernel commit9bf3d2033129quota: check block number when reading the block in quota file and commitd0e36a62bd4c
quota: correct error number infree_dqentry().Signed-off-by Sun Ke <[email protected]>--- tests/ext4/054 | 36 ++++++++++++++++++++++++++++++++++++ tests/ext4/054.out | 1 + 2 files changed, 37 insertions(+) create mode 100755 tests/ext4/054 create mode 100644 tests/ext4/054.outtests/ext4/054 new file +0
-0tests/ext4/054 line 9
Quoted 9 lines
tests/ext4/054 new file +9
-0@@ -0,0 +1,36 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Huawei. All Rights Reserved. +# +# FS QA Test 054 +# +# Regression test for kernel +# commit 9bf3d2033129 quota: check block number when reading the block in quota file +# commit d0e36a62bd4c quota: correct error number in free_dqentry()Better to describe the test in test description as well, e.g. what's the bug and summarise how we're going to test it.
tests/ext4/054 line 14
Quoted 5 lines
tests/ext4/054 new file +5
-0+# +# The test is based on a testcase from Zhang Yi <[email protected]>. +# +. ./common/preamble +_begin_fstest autoIn 'quota' group as well
tests/ext4/054 line 22
Quoted 8 lines
tests/ext4/054 new file +8
-0+ +# real QA test starts here + +# Modify as appropriate. +_require_scratch +_supported_fs ext4 +_require_user fsgqa +_require_user fsgqa2
_require_command"$DEBUGFS_PROG" debugfs
Quoted 9 lines
and use $DEBUGFS_PRG in the test.
tests/ext4/054 line 24
Quoted 2 lines
tests/ext4/054 new file +2
-0+ +_scratch_mkfs "-F -O quota -b 1024" > $seqres.full 2>&1Is 1k block size a required condition to reproduce the bug? Or the following debugfs command requires 1k fs?
Quoted 1 line
tests/ext4/054 new file +1
-0+debugfs -w -R "zap_block -o 0 -l 1 -p 6 -f <3> 1" $SCRATCH_DEV >> $seqres.full 2>&1
Also, this corrupts the filesystem, and post-test fsck complains fs corruption.
We need _require_scratch_nocheck instead of _require_scratch
Thanks,
Eryu
Quoted 38 lines
Some comments are welcomed to describe the detailed test steps, e.g. explain what's the purpose of this debugfs command.
tests/ext4/054 line 30
Quoted 5 lines
tests/ext4/054 new file +5
-0+_scratch_mount >> $seqres.full 2>&1 +chown fsgqa:fsgqa $SCRATCH_MNT >> $seqres.full 2>&1 +touch $SCRATCH_MNT/foo >> $seqres.full 2>&1 +rm -f $SCRATCH_MNT/foo +chown fsgqa2:fsgqa2 $SCRATCH_MNT >> $seqres.full 2>&1And why we need to chown fsgqa:fsgqa first and rm the file and chown to fsgqa2 later.
tests/ext4/054 line 32
Quoted 2 lines
tests/ext4/054 new file +2
-0+ +umount $SCRATCH_MNTIs this required to trigger the bug? If not, this could be removed,
SCRATCH_DEVwill be umounted after each test.tests/ext4/054.out line 1
Quoted 11 lines
tests/ext4/054 new file +4
-0+ +# success, all done +status=0 +exittests/ext4/054.out new file +1
-0@@ -0,0 +1 @@ +QA output created by 054Need "Silence is golden" to indicate this test doesn't print any output.
Thanks,
EryuQuoted 2 lines
Signature · 1 line
2.13.6
Hi, Eryu
Sorry for the delay in replaying.
Quoted 53 lines · Eryu Guan
Quoted 20 lines · Sun Ke
The quota index information in the image is tampered, causing illegal memory access.
It is a regression test for Kernel commit9bf3d2033129quota: check block number when reading the block in quota file and commitd0e36a62bd4c
quota: correct error number infree_dqentry().Signed-off-by Sun Ke <[email protected]>--- tests/ext4/054 | 36 ++++++++++++++++++++++++++++++++++++ tests/ext4/054.out | 1 + 2 files changed, 37 insertions(+)create mode 100755 tests/ext4/054
create mode 100644 tests/ext4/054.outtests/ext4/054 new file +0
-0tests/ext4/054 line 9
Quoted 9 lines
tests/ext4/054 new file +9
-0@@ -0,0 +1,36 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Huawei. All Rights Reserved. +# +# FS QA Test 054 +# +# Regression test for kernel +# commit 9bf3d2033129 quota: check block number when reading the block in quota file +# commit d0e36a62bd4c quota: correct error number in free_dqentry()Better to describe the test in test description as well, e.g. what's the bug and summarise how we're going to test it.
tests/ext4/054 line 14
Quoted 5 lines
tests/ext4/054 new file +5
-0+# +# The test is based on a testcase from Zhang Yi <[email protected]>. +# +. ./common/preamble +_begin_fstest autoIn 'quota' group as well
tests/ext4/054 line 22
Quoted 8 lines
tests/ext4/054 new file +8
-0+ +# real QA test starts here + +# Modify as appropriate. +_require_scratch +_supported_fs ext4 +_require_user fsgqa +_require_user fsgqa2
_require_command"$DEBUGFS_PROG" debugfs
Quoted 7 lines
and use $DEBUGFS_PRG in the test.
tests/ext4/054 line 24
Quoted 2 lines
tests/ext4/054 new file +2
-0+ +_scratch_mkfs "-F -O quota -b 1024" > $seqres.full 2>&1Is 1k block size a required condition to reproduce the bug? Or the following debugfs command requires 1k fs?
the following debugfs command requires 1k fs
Quoted 35 lines
tests/ext4/054 line 25
Quoted 2 lines
tests/ext4/054 new file +1
-0+debugfs -w -R "zap_block -o 0 -l 1 -p 6 -f <3> 1" $SCRATCH_DEV >> $seqres.full 2>&1Some comments are welcomed to describe the detailed test steps, e.g. explain what's the purpose of this debugfs command.
tests/ext4/054 line 30
Quoted 5 lines
tests/ext4/054 new file +5
-0+_scratch_mount >> $seqres.full 2>&1 +chown fsgqa:fsgqa $SCRATCH_MNT >> $seqres.full 2>&1 +touch $SCRATCH_MNT/foo >> $seqres.full 2>&1 +rm -f $SCRATCH_MNT/foo +chown fsgqa2:fsgqa2 $SCRATCH_MNT >> $seqres.full 2>&1And why we need to chown fsgqa:fsgqa first and rm the file and chown to fsgqa2 later.
tests/ext4/054 line 32
Quoted 2 lines
tests/ext4/054 new file +2
-0+ +umount $SCRATCH_MNTIs this required to trigger the bug? If not, this could be removed,
SCRATCH_DEVwill be umounted after each test.tests/ext4/054.out line 1
Quoted 11 lines
tests/ext4/054 new file +4
-0+ +# success, all done +status=0 +exittests/ext4/054.out new file +1
-0@@ -0,0 +1 @@ +QA output created by 054Need "Silence is golden" to indicate this test doesn't print any output.
Quoted 7 lines
Thanks,
EryuQuoted 2 lines
Signature · 1 line
2.13.6.
I will improve it in V2.
Thanks,
Sun Ke