Skip to contentSkip to conversation

generic: add test for boundary in xfs_attr_shortform_verify

PATCH Superseded Pavel Reichl 3 participants 7 messages Sep 14, 2020 – Sep 16, 2020

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover generic: add test for boundary in xfs_attr_shortform_verify

Add test for XFS bug that corrupted metadata if extended attribute name of length 1 was used.

V4 did the following changes:
1) replaced the system-wide cache drop and sleep by _scratch_cycle_mount
2) output of getfattr is grepped for attribute name to simplify expected output
3) dropped explicit _check_scratch_fs
4) renamed the test from 609 to 611 - to resolve the conflict after the recent update of master branch.

Pavel Reichl (1):
generic: add test for boundary in xfs_attr_shortform_verify

 tests/generic/611     | 61 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/611.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 64 insertions(+)
 create mode 100755 tests/generic/611
 create mode 100644 tests/generic/611.out
Signature · 1 line
2.26.2
#1 lore raw

PATCH v4 1/1 generic: add test for boundary in xfs_attr_shortform_verify

Add a regression test to check that the boundary test for the fixed-offset parts of xfs_attr_sf_entry in xfs_attr_shortform_verify is not off by one.

This can be shown by:

touch file
setfattr -n user.a file

With help from Zorro. Thanks very much.

---
 tests/generic/611     | 61 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/611.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 64 insertions(+)
 create mode 100755 tests/generic/611
 create mode 100644 tests/generic/611.out
tests/generic/611 new file +61 -0
new file mode 100755
index 00000000..283327e4
@@ -0,0 +1,61 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
+#
+# FS QA Test 611
+#
+# Verify that metadata won't get corrupted when extended attribute
+# name of size one is set.
+#
+# This test verifies the problem fixed in kernel with commit
+# f4020438fab0 ("xfs: fix boundary test in xfs_attr_shortform_verify")
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_attrs
+
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount
+
+localfile="${SCRATCH_MNT}/testfile"
+
+touch "${localfile}"
+"${SETFATTR_PROG}" -n user.a "${localfile}"
+
+# Make sure that changes are written to disk
+_scratch_cycle_mount
+
+# If the target bug isn't fixed, getfattr fails
+${GETFATTR_PROG} --absolute-names -n user.a $localfile | grep 'user.a'
+
+# Make sure the filesystem isn't corrupted manually
+_scratch_unmount
+
+status=0
+exit
tests/generic/611.out new file +2 -0
new file mode 100644
index 00000000..1ab12434
@@ -0,0 +1,2 @@
+QA output created by 611
+user.a=""
tests/generic/group +1 -0
index 8eba6c98..4af4b494 100644
@@ -613,3 +613,4 @@
 608 auto attr quick dax
 609 auto quick rw
 610 auto quick prealloc zero
+611 auto quick attr
Signature · 1 line
2.26.2
Reviewed-by on v4 1/1
#2 lore raw
Quoted 4 lines · Pavel Reichl

Add a regression test to check that the boundary test for the fixed-offset parts of xfs_attr_sf_entry in xfs_attr_shortform_verify is not off by one.

Quoted 8 lines

This can be shown by:

touch file
setfattr -n user.a file

With help from Zorro. Thanks very much.

Looks good,

--D

Quoted 95 lines
---
 tests/generic/611     | 61 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/611.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 64 insertions(+)
 create mode 100755 tests/generic/611
 create mode 100644 tests/generic/611.out
tests/generic/611 new file +61 -0
new file mode 100755
index 00000000..283327e4
@@ -0,0 +1,61 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
+#
+# FS QA Test 611
+#
+# Verify that metadata won't get corrupted when extended attribute
+# name of size one is set.
+#
+# This test verifies the problem fixed in kernel with commit
+# f4020438fab0 ("xfs: fix boundary test in xfs_attr_shortform_verify")
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_attrs
+
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount
+
+localfile="${SCRATCH_MNT}/testfile"
+
+touch "${localfile}"
+"${SETFATTR_PROG}" -n user.a "${localfile}"
+
+# Make sure that changes are written to disk
+_scratch_cycle_mount
+
+# If the target bug isn't fixed, getfattr fails
+${GETFATTR_PROG} --absolute-names -n user.a $localfile | grep 'user.a'
+
+# Make sure the filesystem isn't corrupted manually
+_scratch_unmount
+
+status=0
+exit
tests/generic/611.out new file +2 -0
new file mode 100644
index 00000000..1ab12434
@@ -0,0 +1,2 @@
+QA output created by 611
+user.a=""
tests/generic/group +1 -0
index 8eba6c98..4af4b494 100644
@@ -613,3 +613,4 @@
 608 auto attr quick dax
 609 auto quick rw
 610 auto quick prealloc zero
+611 auto quick attr
Signature · 1 line
2.26.2
#3 lore raw
In reply to Pavel Reichl
Quoted 74 lines · Pavel Reichl

Add a regression test to check that the boundary test for the fixed-offset parts of xfs_attr_sf_entry in xfs_attr_shortform_verify is not off by one.

This can be shown by:

touch file
setfattr -n user.a file

With help from Zorro. Thanks very much.

---
 tests/generic/611     | 61 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/611.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 64 insertions(+)
 create mode 100755 tests/generic/611
 create mode 100644 tests/generic/611.out
tests/generic/611 new file +48 -0
new file mode 100755
index 00000000..283327e4
@@ -0,0 +1,61 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
+#
+# FS QA Test 611
+#
+# Verify that metadata won't get corrupted when extended attribute
+# name of size one is set.
+#
+# This test verifies the problem fixed in kernel with commit
+# f4020438fab0 ("xfs: fix boundary test in xfs_attr_shortform_verify")
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_attrs
+
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount
+
+localfile="${SCRATCH_MNT}/testfile"
+
+touch "${localfile}"

tests/generic/611 line 58

Quoted 10 lines
tests/generic/611 new file +10 -0
+"${SETFATTR_PROG}" -n user.a "${localfile}"
+
+# Make sure that changes are written to disk
+_scratch_cycle_mount
+
+# If the target bug isn't fixed, getfattr fails
+${GETFATTR_PROG} --absolute-names -n user.a $localfile | grep 'user.a'
+
+# Make sure the filesystem isn't corrupted manually
+_scratch_unmount

If you don't need fsck at here, the _scratch_unmount (and the comment) isn't needed either :)

Quoted 23 lines
tests/generic/611 new file +3 -0
+
+status=0
+exit
tests/generic/611.out new file +2 -0
new file mode 100644
index 00000000..1ab12434
@@ -0,0 +1,2 @@
+QA output created by 611
+user.a=""
tests/generic/group +1 -0
index 8eba6c98..4af4b494 100644
@@ -613,3 +613,4 @@
 608 auto attr quick dax
 609 auto quick rw
 610 auto quick prealloc zero
+611 auto quick attr
Signature · 1 line
2.26.2
#4 lore raw
Quoted 4 lines

If you don't need fsck at here, the _scratch_unmount (and the comment) isn't needed either :)

Hi, thanks for the comment. I guess it's not important for the test itself...should I fix it and send another revision of the patch?

#5 lore raw
Quoted 6 lines · Pavel Reichl
Quoted 4 lines

If you don't need fsck at here, the _scratch_unmount (and the comment) isn't needed either :)

Hi, thanks for the comment. I guess it's not important for the test itself...should I fix it and send another revision of the patch?

I think that depends on if Eryu would like to help to change it when he merges your patch :)

Quoted 1 line
#6 lore raw
Quoted 13 lines · Zorro Lang
Quoted 6 lines · Pavel Reichl
Quoted 4 lines

If you don't need fsck at here, the _scratch_unmount (and the comment) isn't needed either :)

Hi, thanks for the comment. I guess it's not important for the test itself...should I fix it and send another revision of the patch?

I think that depends on if Eryu would like to help to change it when he merges your patch :)

Quoted 1 line

Oh, np, I send next revision in a minute.

Bye.