Skip to contentSkip to conversation

overlay/026: Fix test expectation for newer kernels

PATCH In review Amir Goldstein 2 participants 6 messages Nov 22, 2023 – Dec 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 overlay/026: Fix test expectation for newer kernels

From: Alexander Larsson <[email protected]>

The test checks the expectaion from old kernels that set/get of trusted.overlay.* xattrs is not supported on an overlayfs filesystem.

New kernels support set/get xattr of trusted.overlay.* xattrs, so adapt the test to check that either both set and get work on new kernel, or neither work on old kernel.

---

Zorro,

Per your request on v1 [1], I've added a helper to check escaped overlay xattrs support.

The helper was taken from the patch that adds test overlay/084 [2], and re-factored, but other than that, overlay/084 itself is unchanged, so I am not re-posting it nor any of the other patches in the overlay tests for v6.7-rc1.

Let me know if this works for you.

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20231116075250.ntopaswush4sn2qf@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
[2] https://lore.kernel.org/fstests/[email protected]/

 common/overlay        | 19 +++++++++++++++++++
 tests/overlay/026     | 42 +++++++++++++++++++++++++++++-------------
 tests/overlay/026.out |  2 --
 3 files changed, 48 insertions(+), 15 deletions(-)
common/overlay +19 -0
index 7004187f..8f275228 100644
@@ -201,6 +201,25 @@ _require_scratch_overlay_features()
 	_scratch_unmount
 }
 
+_check_scratch_overlay_xattr_escapes()
+{
+	local testfile=$1
+
+	touch $testfile
+	! ($GETFATTR_PROG -n trusted.overlay.foo $testfile 2>&1 | grep -E -q "not (permitted|supported)")
+}
+
+_require_scratch_overlay_xattr_escapes()
+{
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+
+        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
+                  _notrun "xattr escaping is not supported by overlay"
+
+	_scratch_unmount
+}
+
 _require_scratch_overlay_verity()
 {
 	local lowerdirs="$OVL_BASE_SCRATCH_MNT/$OVL_UPPER:$OVL_BASE_SCRATCH_MNT/$OVL_LOWER"
tests/overlay/026 +29 -13

55 lines not on this page · raw message

tests/overlay/026.out +0 -2
index c4572d67..53030009 100644
@@ -2,5 +2,3 @@ QA output created by 026
 # file: SCRATCH_MNT/testf0
 trusted.overlayfsrz="n"
 
-setfattr: SCRATCH_MNT/testf1: Operation not supported
-SCRATCH_MNT/testf1: trusted.overlay.fsz: Operation not supported
Signature · 1 line
2.34.1
#1 lore raw
Quoted 19 lines · Amir Goldstein

From: Alexander Larsson <[email protected]>

The test checks the expectaion from old kernels that set/get of trusted.overlay.* xattrs is not supported on an overlayfs filesystem.

New kernels support set/get xattr of trusted.overlay.* xattrs, so adapt the test to check that either both set and get work on new kernel, or neither work on old kernel.

---

Zorro,

Per your request on v1 [1], I've added a helper to check escaped overlay xattrs support.

Quoted 6 lines

The helper was taken from the patch that adds test overlay/084 [2], and re-factored, but other than that, overlay/084 itself is unchanged, so I am not re-posting it nor any of the other patches in the overlay tests for v6.7-rc1.

Let me know if this works for you.

Ping.

Quoted 115 lines

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20231116075250.ntopaswush4sn2qf@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
[2] https://lore.kernel.org/fstests/[email protected]/

 common/overlay        | 19 +++++++++++++++++++
 tests/overlay/026     | 42 +++++++++++++++++++++++++++++-------------
 tests/overlay/026.out |  2 --
 3 files changed, 48 insertions(+), 15 deletions(-)
common/overlay +19 -0
index 7004187f..8f275228 100644
@@ -201,6 +201,25 @@ _require_scratch_overlay_features()
        _scratch_unmount
 }
 
+_check_scratch_overlay_xattr_escapes()
+{
+       local testfile=$1
+
+       touch $testfile
+       ! ($GETFATTR_PROG -n trusted.overlay.foo $testfile 2>&1 | grep -E -q "not (permitted|supported)")
+}
+
+_require_scratch_overlay_xattr_escapes()
+{
+       _scratch_mkfs > /dev/null 2>&1
+       _scratch_mount
+
+        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
+                  _notrun "xattr escaping is not supported by overlay"
+
+       _scratch_unmount
+}
+
 _require_scratch_overlay_verity()
 {
        local lowerdirs="$OVL_BASE_SCRATCH_MNT/$OVL_UPPER:$OVL_BASE_SCRATCH_MNT/$OVL_LOWER"
tests/overlay/026 +29 -13
index 77030d20..25c70bc8 100755
@@ -52,26 +52,42 @@ touch $SCRATCH_MNT/testf1
 # getfattr    ok         no attr     ok    ok
 #
 $SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
-  $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
+  $SCRATCH_MNT/testf0 2>&1 | tee -a $seqres.full | _filter_scratch
 
 _getfattr --absolute-names -n "trusted.overlayfsrz" \
-  $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
+  $SCRATCH_MNT/testf0 2>&1 | tee -a $seqres.full | _filter_scratch
 
-# {s,g}etfattr of "trusted.overlay.xxx" should fail.
+# {s,g}etfattr of "trusted.overlay.xxx" fail on older kernels
 # The errno returned varies among kernel versions,
-#            v4.3/7   v4.8-rc1    v4.8       v4.10
-# setfattr  not perm  not perm   not perm   not supp
-# getfattr  no attr   no attr    not perm   not supp
+#            v4.3/7   v4.8-rc1    v4.8       v4.10     v6.7
+# setfattr  not perm  not perm   not perm   not supp  ok
+# getfattr  no attr   no attr    not perm   not supp  ok
 #
-# Consider "Operation not {supported,permitted}" pass.
+# Consider "Operation not {supported,permitted}" pass for old kernels.
 #
-$SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
-  $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
-  sed -e 's/permitted/supported/g'
+if _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/testf0; then
+       setexp=""
+       getexp="No such attribute"
+else
+       setexp="Operation not supported"
+       getexp="Operation not supported"
+fi
 
-_getfattr --absolute-names -n "trusted.overlay.fsz" \
-  $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
-  sed -e 's/permitted/supported/g'
+getres=$(_getfattr --absolute-names -n "trusted.overlay.fsz" \
+  $SCRATCH_MNT/testf1 2>&1 | tee -a $seqres.full | _filter_scratch | \
+  sed 's/permitted/supported/')
+
+[[ "$getres" =~ "$getexp" ]] || echo unexpected getattr result: $getres
+
+setres=$($SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
+  $SCRATCH_MNT/testf1 2>&1 | tee -a $seqres.full |_filter_scratch | \
+  sed -e 's/permitted/supported/g')
+
+if [ "$setexp" ]; then
+       [[ "$setres" =~ "$expres" ]] || echo unexpected setattr result: $setres
+else
+       [[ "$setres" == "" ]] || echo unexpected setattr result: $setres
+fi
 
 # success, all done
 status=0
tests/overlay/026.out +0 -3
index c4572d67..53030009 100644
@@ -2,5 +2,3 @@ QA output created by 026
 # file: SCRATCH_MNT/testf0
 trusted.overlayfsrz="n"
 
-setfattr: SCRATCH_MNT/testf1: Operation not supported
-SCRATCH_MNT/testf1: trusted.overlay.fsz: Operation not supported
--

2.34.1

#2 lore raw
In reply to Amir Goldstein
Quoted 57 lines · Amir Goldstein

From: Alexander Larsson <[email protected]>

The test checks the expectaion from old kernels that set/get of trusted.overlay.* xattrs is not supported on an overlayfs filesystem.

New kernels support set/get xattr of trusted.overlay.* xattrs, so adapt the test to check that either both set and get work on new kernel, or neither work on old kernel.

---

Zorro,

Per your request on v1 [1], I've added a helper to check escaped overlay xattrs support.

The helper was taken from the patch that adds test overlay/084 [2], and re-factored, but other than that, overlay/084 itself is unchanged, so I am not re-posting it nor any of the other patches in the overlay tests for v6.7-rc1.

Let me know if this works for you.

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20231116075250.ntopaswush4sn2qf@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
[2] https://lore.kernel.org/fstests/[email protected]/

 common/overlay        | 19 +++++++++++++++++++
 tests/overlay/026     | 42 +++++++++++++++++++++++++++++-------------
 tests/overlay/026.out |  2 --
 3 files changed, 48 insertions(+), 15 deletions(-)
common/overlay +9 -0
index 7004187f..8f275228 100644
@@ -201,6 +201,25 @@ _require_scratch_overlay_features()
 	_scratch_unmount
 }
 
+_check_scratch_overlay_xattr_escapes()
+{
+	local testfile=$1
+
+	touch $testfile
+	! ($GETFATTR_PROG -n trusted.overlay.foo $testfile 2>&1 | grep -E -q "not (permitted|supported)")
+}
+
+_require_scratch_overlay_xattr_escapes()

common/overlay _require_scratch_overlay_features() · line 222

Quoted 10 lines
common/overlay +10 -0
+{
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+
+        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
+                  _notrun "xattr escaping is not supported by overlay"
+
+	_scratch_unmount
+}
+

Hi Amir,

Sorry for this late review, got a little busy on other things recently. Won't this patch be conflict with another patchset which you/Alex have sent:
https://lore.kernel.org/fstests/[email protected]/

So you'll rebase that patchset on this, right?

Thanks,
Zorro

Quoted 76 lines
common/overlay +0 -0
 _require_scratch_overlay_verity()
 {
 	local lowerdirs="$OVL_BASE_SCRATCH_MNT/$OVL_UPPER:$OVL_BASE_SCRATCH_MNT/$OVL_LOWER"
tests/overlay/026 +29 -13
index 77030d20..25c70bc8 100755
@@ -52,26 +52,42 @@ touch $SCRATCH_MNT/testf1
 # getfattr    ok         no attr     ok    ok
 #
 $SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
-  $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
+  $SCRATCH_MNT/testf0 2>&1 | tee -a $seqres.full | _filter_scratch
 
 _getfattr --absolute-names -n "trusted.overlayfsrz" \
-  $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
+  $SCRATCH_MNT/testf0 2>&1 | tee -a $seqres.full | _filter_scratch
 
-# {s,g}etfattr of "trusted.overlay.xxx" should fail.
+# {s,g}etfattr of "trusted.overlay.xxx" fail on older kernels
 # The errno returned varies among kernel versions,
-#            v4.3/7   v4.8-rc1    v4.8       v4.10
-# setfattr  not perm  not perm   not perm   not supp
-# getfattr  no attr   no attr    not perm   not supp
+#            v4.3/7   v4.8-rc1    v4.8       v4.10     v6.7
+# setfattr  not perm  not perm   not perm   not supp  ok
+# getfattr  no attr   no attr    not perm   not supp  ok
 #
-# Consider "Operation not {supported,permitted}" pass.
+# Consider "Operation not {supported,permitted}" pass for old kernels.
 #
-$SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
-  $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
-  sed -e 's/permitted/supported/g'
+if _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/testf0; then
+	setexp=""
+	getexp="No such attribute"
+else
+	setexp="Operation not supported"
+	getexp="Operation not supported"
+fi
 
-_getfattr --absolute-names -n "trusted.overlay.fsz" \
-  $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
-  sed -e 's/permitted/supported/g'
+getres=$(_getfattr --absolute-names -n "trusted.overlay.fsz" \
+  $SCRATCH_MNT/testf1 2>&1 | tee -a $seqres.full | _filter_scratch | \
+  sed 's/permitted/supported/')
+
+[[ "$getres" =~ "$getexp" ]] || echo unexpected getattr result: $getres
+
+setres=$($SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
+  $SCRATCH_MNT/testf1 2>&1 | tee -a $seqres.full |_filter_scratch | \
+  sed -e 's/permitted/supported/g')
+
+if [ "$setexp" ]; then
+	[[ "$setres" =~ "$expres" ]] || echo unexpected setattr result: $setres
+else
+	[[ "$setres" == "" ]] || echo unexpected setattr result: $setres
+fi
 
 # success, all done
 status=0
tests/overlay/026.out +0 -2
index c4572d67..53030009 100644
@@ -2,5 +2,3 @@ QA output created by 026
 # file: SCRATCH_MNT/testf0
 trusted.overlayfsrz="n"
 
-setfattr: SCRATCH_MNT/testf1: Operation not supported
-SCRATCH_MNT/testf1: trusted.overlay.fsz: Operation not supported
Signature · 1 line
2.34.1
#3 lore raw
Quoted 72 lines · Zorro Lang
Quoted 57 lines · Amir Goldstein

From: Alexander Larsson <[email protected]>

The test checks the expectaion from old kernels that set/get of trusted.overlay.* xattrs is not supported on an overlayfs filesystem.

New kernels support set/get xattr of trusted.overlay.* xattrs, so adapt the test to check that either both set and get work on new kernel, or neither work on old kernel.

---

Zorro,

Per your request on v1 [1], I've added a helper to check escaped overlay xattrs support.

The helper was taken from the patch that adds test overlay/084 [2], and re-factored, but other than that, overlay/084 itself is unchanged, so I am not re-posting it nor any of the other patches in the overlay tests for v6.7-rc1.

Let me know if this works for you.

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20231116075250.ntopaswush4sn2qf@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
[2] https://lore.kernel.org/fstests/[email protected]/

 common/overlay        | 19 +++++++++++++++++++
 tests/overlay/026     | 42 +++++++++++++++++++++++++++++-------------
 tests/overlay/026.out |  2 --
 3 files changed, 48 insertions(+), 15 deletions(-)
common/overlay +9 -0
index 7004187f..8f275228 100644
@@ -201,6 +201,25 @@ _require_scratch_overlay_features()
      _scratch_unmount
 }
 
+_check_scratch_overlay_xattr_escapes()
+{
+     local testfile=$1
+
+     touch $testfile
+     ! ($GETFATTR_PROG -n trusted.overlay.foo $testfile 2>&1 | grep -E -q "not (permitted|supported)")
+}
+
+_require_scratch_overlay_xattr_escapes()

common/overlay _require_scratch_overlay_features() · line 222

Quoted 10 lines
common/overlay +10 -0
+{
+     _scratch_mkfs > /dev/null 2>&1
+     _scratch_mount
+
+        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
+                  _notrun "xattr escaping is not supported by overlay"
+
+     _scratch_unmount
+}
+

Hi Amir,

Quoted 5 lines

Sorry for this late review, got a little busy on other things recently. Won't this patch be conflict with another patchset which you/Alex have sent:
https://lore.kernel.org/fstests/[email protected]/

So you'll rebase that patchset on this, right?

I rebased and pushed to this branch:
https://github.com/amir73il/xfstests/commits/overlayfs-devel

If you want I can re-post the entire series, but really, the only change is the common/overlay chunk in the first patch which should be ignored. The version of _require_scratch_overlay_xattr_escapes() in this patch is newer.

If you remove the overlay/common chunk from the overlay/084 patch, it will apply cleanly.

Thanks,
Amir.

Reviewed-by
#4 lore raw
Quoted 77 lines · Amir Goldstein
Quoted 76 lines · Zorro Lang
Quoted 57 lines · Amir Goldstein

From: Alexander Larsson <[email protected]>

The test checks the expectaion from old kernels that set/get of trusted.overlay.* xattrs is not supported on an overlayfs filesystem.

New kernels support set/get xattr of trusted.overlay.* xattrs, so adapt the test to check that either both set and get work on new kernel, or neither work on old kernel.

---

Zorro,

Per your request on v1 [1], I've added a helper to check escaped overlay xattrs support.

The helper was taken from the patch that adds test overlay/084 [2], and re-factored, but other than that, overlay/084 itself is unchanged, so I am not re-posting it nor any of the other patches in the overlay tests for v6.7-rc1.

Let me know if this works for you.

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20231116075250.ntopaswush4sn2qf@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
[2] https://lore.kernel.org/fstests/[email protected]/

 common/overlay        | 19 +++++++++++++++++++
 tests/overlay/026     | 42 +++++++++++++++++++++++++++++-------------
 tests/overlay/026.out |  2 --
 3 files changed, 48 insertions(+), 15 deletions(-)
common/overlay +9 -0
index 7004187f..8f275228 100644
@@ -201,6 +201,25 @@ _require_scratch_overlay_features()
      _scratch_unmount
 }
 
+_check_scratch_overlay_xattr_escapes()
+{
+     local testfile=$1
+
+     touch $testfile
+     ! ($GETFATTR_PROG -n trusted.overlay.foo $testfile 2>&1 | grep -E -q "not (permitted|supported)")
+}
+
+_require_scratch_overlay_xattr_escapes()

common/overlay _require_scratch_overlay_features() · line 222

Quoted 10 lines
common/overlay +10 -0
+{
+     _scratch_mkfs > /dev/null 2>&1
+     _scratch_mount
+
+        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
+                  _notrun "xattr escaping is not supported by overlay"
+
+     _scratch_unmount
+}
+

Hi Amir,

Sorry for this late review, got a little busy on other things recently. Won't this patch be conflict with another patchset which you/Alex have sent:
https://lore.kernel.org/fstests/[email protected]/

Quoted 7 lines
Quoted 1 line

So you'll rebase that patchset on this, right?

I rebased and pushed to this branch:
https://github.com/amir73il/xfstests/commits/overlayfs-devel

If you want I can re-post the entire series, but really, the only change is the common/overlay chunk in the first patch which should be ignored.

Hi Amir,

I just tried, there're two _require_scratch_overlay_xattr_escapes() in common/overlay [1]. So please rebase and re-send that patchset, then I can merge them easily and clearly. This patch is good to me, let me give RVB to this patch at first.

Thanks,
Zorro

[1]
_require_scratch_overlay_xattr_escapes()

{
        _scratch_mkfs > /dev/null 2>&1
        _scratch_mount

        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
                  _notrun "xattr escaping is not supported by overlay"

        _scratch_unmount
}

_require_scratch_overlay_xattr_escapes()
{
_scratch_mkfs > /dev/null 2>&1
_overlay_scratch_mount_dirs $OVL_BASE_SCRATCH_MNT/$OVL_LOWER $OVL_BASE_SCRATCH_MNT/$OVL_UPPER $OVL_BASE_SCRATCH_MNT/$OVL_WORK -o rw

touch $SCRATCH_MNT/file
(getfattr -n trusted.overlay.foo $SCRATCH_MNT/file 2>&1 | grep -q "not supported") && \
_notrun "xattr escaping is not supported by overlay"

_scratch_unmount
}

Quoted 9 lines

The version of _require_scratch_overlay_xattr_escapes() in this patch is newer.

If you remove the overlay/common chunk from the overlay/084 patch, it will apply cleanly.

Thanks,
Amir.

#5 lore raw
Quoted 84 lines · Zorro Lang
Quoted 82 lines · Amir Goldstein
Quoted 72 lines · Zorro Lang
Quoted 57 lines · Amir Goldstein

From: Alexander Larsson <[email protected]>

The test checks the expectaion from old kernels that set/get of trusted.overlay.* xattrs is not supported on an overlayfs filesystem.

New kernels support set/get xattr of trusted.overlay.* xattrs, so adapt the test to check that either both set and get work on new kernel, or neither work on old kernel.

---

Zorro,

Per your request on v1 [1], I've added a helper to check escaped overlay xattrs support.

The helper was taken from the patch that adds test overlay/084 [2], and re-factored, but other than that, overlay/084 itself is unchanged, so I am not re-posting it nor any of the other patches in the overlay tests for v6.7-rc1.

Let me know if this works for you.

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20231116075250.ntopaswush4sn2qf@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
[2] https://lore.kernel.org/fstests/[email protected]/

 common/overlay        | 19 +++++++++++++++++++
 tests/overlay/026     | 42 +++++++++++++++++++++++++++++-------------
 tests/overlay/026.out |  2 --
 3 files changed, 48 insertions(+), 15 deletions(-)
common/overlay +9 -0
index 7004187f..8f275228 100644
@@ -201,6 +201,25 @@ _require_scratch_overlay_features()
      _scratch_unmount
 }
 
+_check_scratch_overlay_xattr_escapes()
+{
+     local testfile=$1
+
+     touch $testfile
+     ! ($GETFATTR_PROG -n trusted.overlay.foo $testfile 2>&1 | grep -E -q "not (permitted|supported)")
+}
+
+_require_scratch_overlay_xattr_escapes()

common/overlay _require_scratch_overlay_features() · line 222

Quoted 10 lines
common/overlay +10 -0
+{
+     _scratch_mkfs > /dev/null 2>&1
+     _scratch_mount
+
+        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
+                  _notrun "xattr escaping is not supported by overlay"
+
+     _scratch_unmount
+}
+

Hi Amir,

Quoted 5 lines

Sorry for this late review, got a little busy on other things recently. Won't this patch be conflict with another patchset which you/Alex have sent:
https://lore.kernel.org/fstests/[email protected]/

So you'll rebase that patchset on this, right?

I rebased and pushed to this branch:
https://github.com/amir73il/xfstests/commits/overlayfs-devel

Quoted 7 lines
Quoted 2 lines

If you want I can re-post the entire series, but really, the only change is the common/overlay chunk in the first patch which should be ignored.

Hi Amir,

I just tried, there're two _require_scratch_overlay_xattr_escapes() in common/overlay [1].

Yes, as I said, the one from *this* patch is the correct one the other one is obsolete.

Quoted 2 lines

So please rebase and re-send that patchset, then I can merge them easily and clearly.

Ok. Sent v2.
You should apply it on top of this patch.

Thanks,
Amir.