fstests: btrfs: a new test case to verify scrub and rescue=idatacsums
PATCH 1/1 fstests: btrfs: a new test case to verify scrub and rescue=idatacsums
There is a kernel bug report that scrub will trigger a NULL pointer dereference when rescue=idatacsums mount option is provided.
Add a test case for such situation, to verify kernel can gracefully reject scrub when there is no csum tree.
--- tests/btrfs/336 | 32 ++++++++++++++++++++++++++++++++ tests/btrfs/336.out | 2 ++ 2 files changed, 34 insertions(+) create mode 100755 tests/btrfs/336 create mode 100644 tests/btrfs/336.out
tests/btrfs/336 new file +32 -0
@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 336 +# +# Make sure read-only scrub won't cause NULL pointer dereference with +# rescue=idatacsums mount option +# +. ./common/preamble +_begin_fstest auto scrub quick + +_fixed_by_kernel_commit 6aecd91a5c5b \ + "btrfs: avoid NULL pointer dereference if no valid extent tree" + +_require_scratch +_scratch_mkfs >> $seqres.full + +_try_scratch_mount "-o ro,rescue=ignoredatacsums" > /dev/null 2>&1 || + _notrun "rescue=ignoredatacsums mount option not supported" + +# For unpatched kernel this will cause NULL pointer dereference and crash the kernel. +# For patched kernel scrub will be gracefully rejected. +$BTRFS_UTIL_PROG scrub start -Br $SCRATCH_MNT >> $seqres.full 2>&1 + +_scratch_unmount + +echo "Silence is golden" + +# success, all done +status=0 +exit
tests/btrfs/336.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 336 +Silence is golden
Signature · 1 line
2.47.1
Looks good,
Quoted 35 lines · Qu Wenruo
There is a kernel bug report that scrub will trigger a NULL pointer dereference when rescue=idatacsums mount option is provided.
Add a test case for such situation, to verify kernel can gracefully reject scrub when there is no csum tree.
Signed-off-by Qu Wenruo <[email protected]>--- tests/btrfs/336 | 32 ++++++++++++++++++++++++++++++++ tests/btrfs/336.out | 2 ++ 2 files changed, 34 insertions(+) create mode 100755 tests/btrfs/336 create mode 100644 tests/btrfs/336.outtests/btrfs/336 new file +14
-0@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 336 +# +# Make sure read-only scrub won't cause NULL pointer dereference with +# rescue=idatacsums mount option +# +. ./common/preamble +_begin_fstest auto scrub quick + +_fixed_by_kernel_commit 6aecd91a5c5b \ + "btrfs: avoid NULL pointer dereference if no valid extent tree"
tests/btrfs/336 line 24
Quoted 10 lines
tests/btrfs/336 new file +10
-0+ +_require_scratch +_scratch_mkfs >> $seqres.full + +_try_scratch_mount "-o ro,rescue=ignoredatacsums" > /dev/null 2>&1 || + _notrun "rescue=ignoredatacsums mount option not supported" + +# For unpatched kernel this will cause NULL pointer dereference and crash the kernel. +# For patched kernel scrub will be gracefully rejected. +$BTRFS_UTIL_PROG scrub start -Br $SCRATCH_MNT >> $seqres.full 2>&1
If the scrub is supposed to fail, as the comment says, then we should check that it fails.
Right now we're ignoring whether it succeeds or fails.
Otherwise it looks fine, thanks.
Quoted 20 lines
tests/btrfs/336 new file +8
-0+ +_scratch_unmount + +echo "Silence is golden" + +# success, all done +status=0 +exittests/btrfs/336.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 336 +Silence is golden --2.47.1
Quoted 42 lines · Filipe Manana
Quoted 41 lines · Qu Wenruo
There is a kernel bug report that scrub will trigger a NULL pointer dereference when rescue=idatacsums mount option is provided.
Add a test case for such situation, to verify kernel can gracefully reject scrub when there is no csum tree.
Signed-off-by Qu Wenruo <[email protected]>--- tests/btrfs/336 | 32 ++++++++++++++++++++++++++++++++ tests/btrfs/336.out | 2 ++ 2 files changed, 34 insertions(+)create mode 100755 tests/btrfs/336
create mode 100644 tests/btrfs/336.outtests/btrfs/336 new file +20
-0@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 336 +# +# Make sure read-only scrub won't cause NULL pointer dereference with +# rescue=idatacsums mount option +# +. ./common/preamble +_begin_fstest auto scrub quick + +_fixed_by_kernel_commit 6aecd91a5c5b \ + "btrfs: avoid NULL pointer dereference if no valid extent tree" + +_require_scratch +_scratch_mkfs >> $seqres.full + +_try_scratch_mount "-o ro,rescue=ignoredatacsums" > /dev/null 2>&1 || + _notrun "rescue=ignoredatacsums mount option not supported"
Quoted 8 lines
tests/btrfs/336 line 24
Quoted 4 lines
tests/btrfs/336 new file +4
-0+ +# For unpatched kernel this will cause NULL pointer dereference and crash the kernel. +# For patched kernel scrub will be gracefully rejected. +$BTRFS_UTIL_PROG scrub start -Br $SCRATCH_MNT >> $seqres.full 2>&1If the scrub is supposed to fail, as the comment says, then we should check that it fails.
Right now we're ignoring whether it succeeds or fails.
Currently it indeed fails for patched kernel, but I'm not sure if it will keep so in the future.
E.g. we can still properly scrub metadata chunks, and for data chunks we may even delayed the csum tree lookup so that if we got an empty data block group, we just do an early exit.
Or should I do the failure check, and update the test case when the kernel behavior changes in the future?
Thanks,
Qu
Quoted 3 lines
Otherwise it looks fine, thanks.
Quoted 58 lines · Qu Wenruo
Quoted 42 lines · Filipe Manana
Quoted 41 lines · Qu Wenruo
There is a kernel bug report that scrub will trigger a NULL pointer dereference when rescue=idatacsums mount option is provided.
Add a test case for such situation, to verify kernel can gracefully reject scrub when there is no csum tree.
Signed-off-by Qu Wenruo <[email protected]>--- tests/btrfs/336 | 32 ++++++++++++++++++++++++++++++++ tests/btrfs/336.out | 2 ++ 2 files changed, 34 insertions(+)create mode 100755 tests/btrfs/336
create mode 100644 tests/btrfs/336.outtests/btrfs/336 new file +20
-0@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 336 +# +# Make sure read-only scrub won't cause NULL pointer dereference with +# rescue=idatacsums mount option +# +. ./common/preamble +_begin_fstest auto scrub quick + +_fixed_by_kernel_commit 6aecd91a5c5b \ + "btrfs: avoid NULL pointer dereference if no valid extent tree" + +_require_scratch +_scratch_mkfs >> $seqres.full + +_try_scratch_mount "-o ro,rescue=ignoredatacsums" > /dev/null 2>&1 || + _notrun "rescue=ignoredatacsums mount option not supported"Quoted 8 lines
tests/btrfs/336 line 24
Quoted 4 lines
tests/btrfs/336 new file +4
-0+ +# For unpatched kernel this will cause NULL pointer dereference and crash the kernel. +# For patched kernel scrub will be gracefully rejected. +$BTRFS_UTIL_PROG scrub start -Br $SCRATCH_MNT >> $seqres.full 2>&1If the scrub is supposed to fail, as the comment says, then we should check that it fails.
Right now we're ignoring whether it succeeds or fails.Currently it indeed fails for patched kernel, but I'm not sure if it will keep so in the future.
Quoted 6 lines
E.g. we can still properly scrub metadata chunks, and for data chunks we may even delayed the csum tree lookup so that if we got an empty data block group, we just do an early exit.
Or should I do the failure check, and update the test case when the kernel behavior changes in the future?
It should check the current expected behaviour, and if that changes one day, then update it.
I always find it terribly confusing when something is called and we ignore its stdout/stderr and exit status - it makes one wonder why the command is being called, if the author forgot about checking what's supposed to happen.
Thanks.
Quoted 9 lines
Thanks,
QuQuoted 3 lines
Otherwise it looks fine, thanks.
Quoted 66 lines · Filipe Manana
Quoted 58 lines · Qu Wenruo
Quoted 42 lines · Filipe Manana
Quoted 41 lines · Qu Wenruo
There is a kernel bug report that scrub will trigger a NULL pointer dereference when rescue=idatacsums mount option is provided.
Add a test case for such situation, to verify kernel can gracefully reject scrub when there is no csum tree.
Signed-off-by Qu Wenruo <[email protected]>--- tests/btrfs/336 | 32 ++++++++++++++++++++++++++++++++ tests/btrfs/336.out | 2 ++ 2 files changed, 34 insertions(+)create mode 100755 tests/btrfs/336
create mode 100644 tests/btrfs/336.outtests/btrfs/336 new file +20
-0@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 336 +# +# Make sure read-only scrub won't cause NULL pointer dereference with +# rescue=idatacsums mount option +# +. ./common/preamble +_begin_fstest auto scrub quick + +_fixed_by_kernel_commit 6aecd91a5c5b \ + "btrfs: avoid NULL pointer dereference if no valid extent tree" + +_require_scratch +_scratch_mkfs >> $seqres.full + +_try_scratch_mount "-o ro,rescue=ignoredatacsums" > /dev/null 2>&1 || + _notrun "rescue=ignoredatacsums mount option not supported"Quoted 8 lines
tests/btrfs/336 line 24
Quoted 4 lines
tests/btrfs/336 new file +4
-0+ +# For unpatched kernel this will cause NULL pointer dereference and crash the kernel. +# For patched kernel scrub will be gracefully rejected. +$BTRFS_UTIL_PROG scrub start -Br $SCRATCH_MNT >> $seqres.full 2>&1If the scrub is supposed to fail, as the comment says, then we should check that it fails.
Right now we're ignoring whether it succeeds or fails.Currently it indeed fails for patched kernel, but I'm not sure if it will keep so in the future.
Quoted 6 lines
E.g. we can still properly scrub metadata chunks, and for data chunks we may even delayed the csum tree lookup so that if we got an empty data block group, we just do an early exit.
Or should I do the failure check, and update the test case when the kernel behavior changes in the future?
Quoted 7 lines
It should check the current expected behaviour, and if that changes one day, then update it.
I always find it terribly confusing when something is called and we ignore its stdout/stderr and exit status - it makes one wonder why the command is being called, if the author forgot about checking what's supposed to happen.
Makes sense.
As there is no way to check if the kernel has commit fix 6aecd91a5c5b testcase will crash the system. That's a bit concerning.
Thanks, Anand
Quoted 77 lines · Anand Jain
Quoted 68 lines · Filipe Manana
Quoted 60 lines · Qu Wenruo
Quoted 44 lines · Filipe Manana
Quoted 43 lines · Qu Wenruo
There is a kernel bug report that scrub will trigger a NULL pointer dereference when rescue=idatacsums mount option is provided.
Add a test case for such situation, to verify kernel can gracefully reject scrub when there is no csum tree.
Signed-off-by Qu Wenruo <[email protected]>---
tests/btrfs/336 | 32 ++++++++++++++++++++++++++++++++ tests/btrfs/336.out | 2 ++2 files changed, 34 insertions(+)create mode 100755 tests/btrfs/336
create mode 100644 tests/btrfs/336.outtests/btrfs/336 new file +14
-0@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 336 +# +# Make sure read-only scrub won't cause NULL pointer dereference with +# rescue=idatacsums mount option +# +. ./common/preamble +_begin_fstest auto scrub quick + +_fixed_by_kernel_commit 6aecd91a5c5b \ + "btrfs: avoid NULL pointer dereference if no valid extenttree"
tests/btrfs/336 new file +7
-0+ +_require_scratch +_scratch_mkfs >> $seqres.full + +_try_scratch_mount "-o ro,rescue=ignoredatacsums" > /dev/null 2>&1 || + _notrun "rescue=ignoredatacsums mount option not supported" +Quoted 8 lines
Quoted 4 lines
+# For unpatched kernel this will cause NULL pointer dereference and crash the kernel.
+# For patched kernel scrub will be gracefully rejected. +$BTRFS_UTIL_PROG scrub start -Br $SCRATCH_MNT >> $seqres.full 2>&1If the scrub is supposed to fail, as the comment says, then we should check that it fails.
Right now we're ignoring whether it succeeds or fails.Currently it indeed fails for patched kernel, but I'm not sure if it will keep so in the future.
Quoted 6 lines
E.g. we can still properly scrub metadata chunks, and for data chunks we may even delayed the csum tree lookup so that if we got an empty data block group, we just do an early exit.
Or should I do the failure check, and update the test case when the kernel behavior changes in the future?
Quoted 7 lines
It should check the current expected behaviour, and if that changes one day, then update it.
I always find it terribly confusing when something is called and we ignore its stdout/stderr and exit status - it makes one wonder why the command is being called, if the author forgot about checking what's supposed to happen.
Quoted 4 lines
Makes sense.
As there is no way to check if the kernel has commit fix
6aecd91a5c5btestcase will crash the system. That's a bit concerning.
In that case you can add the test case to dangerous group at merge time.
Thanks,
Qu
Quoted 4 lines
Thanks, Anand
Quoted 86 lines · Qu Wenruo
Quoted 83 lines · Anand Jain
Quoted 78 lines · Filipe Manana
Quoted 62 lines · Qu Wenruo
Quoted 46 lines · Filipe Manana
Quoted 45 lines · Qu Wenruo
There is a kernel bug report that scrub will trigger a NULL pointer dereference when rescue=idatacsums mount option is provided.
Add a test case for such situation, to verify kernel can gracefully reject scrub when there is no csum tree.
Signed-off-by Qu Wenruo <[email protected]>---
tests/btrfs/336 | 32 ++++++++++++++++++++++++++++++++ tests/btrfs/336.out | 2 ++2 files changed, 34 insertions(+)create mode 100755 tests/btrfs/336
create mode 100644 tests/btrfs/336.outtests/btrfs/336 new file +7
-0@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 336 +# +# Make sure read-only scrub won't cause NULL pointer dereferencewith
tests/btrfs/336 new file +7
-0+# rescue=idatacsums mount option +# +. ./common/preamble +_begin_fstest auto scrub quick + +_fixed_by_kernel_commit 6aecd91a5c5b \ + "btrfs: avoid NULL pointer dereference if no valid extenttree"
tests/btrfs/336 new file +5
-0+ +_require_scratch +_scratch_mkfs >> $seqres.full + +_try_scratch_mount "-o ro,rescue=ignoredatacsums" > /dev/null2>&1 ||
+_notrun"rescue=ignoredatacsums mount option not supported" +Quoted 8 lines
Quoted 4 lines
+# For unpatched kernel this will cause NULL pointer dereference and crash the kernel.
+# For patched kernel scrub will be gracefully rejected. +$BTRFS_UTIL_PROG scrub start -Br $SCRATCH_MNT >> $seqres.full 2>&1If the scrub is supposed to fail, as the comment says, then we should check that it fails.
Right now we're ignoring whether it succeeds or fails.Currently it indeed fails for patched kernel, but I'm not sure if it will keep so in the future.
Quoted 6 lines
E.g. we can still properly scrub metadata chunks, and for data chunks we may even delayed the csum tree lookup so that if we got an empty data block group, we just do an early exit.
Or should I do the failure check, and update the test case when the kernel behavior changes in the future?
It should check the current expected behaviour, and if that changes one day, then update it.
I always find it terribly confusing when something is called and we ignore its stdout/stderr and exit status - it makes one wonder why the command is being called, if the author forgot about checking what's supposed to happen.
Quoted 7 lines
Quoted 4 lines
Makes sense.
As there is no way to check if the kernel has commit fix
6aecd91a5c5btestcase will crash the system. That's a bit concerning.In that case you can add the test case to dangerous group at merge time.
Oh, right — we can use dangerous.
I thought you were still sending v2 with Filipe's review comments?
在 2025/5/13 19:27, Anand Jain 写道:
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Makes sense.
As there is no way to check if the kernel has commit fix
6aecd91a5c5btestcase will crash the system. That's a bit concerning.
Quoted 7 lines
Quoted 2 lines
In that case you can add the test case to dangerous group at merge time.
Oh, right — we can use dangerous.
I thought you were still sending v2 with Filipe's review comments?
Well, you reviewed the v2 version and applied, thus I guess it's easier to add the group on your side:
https://lore.kernel.org/linux-btrfs/[email protected]/
Thanks,
Qu