2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
7 # Overlayfs should only filter out xattr starting with
8 # "trusted.overlay.", not "trusted.overlay".
10 # Setting xattrs like "trusted.overlay.xxx" is not allowed.
11 # Setting xattrs like "trusted.overlayxxx" is allowed.
13 # v4.8-rc1 introduced a regression that we can't set xattrs
14 # like "trusted.overlayxxx". Kernel commit below fixed it
16 # fe2b75952347 ovl: Fix OVL_XATTR_PREFIX
18 # This case tests both get/set of these 2 kinds of xattrs.
20 # Pattern "trusted.overlay.xxx" should fail, however the
21 # errno returned by set/get varies among kernel versions.
22 # Pattern "trusted.overlayxxx" shold always work.
24 # This reproducer was originally written by
25 # Miklos Szeredi <mszeredi@redhat.com>
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # remove previous $seqres.full before test
50 # real QA test starts here
52 # Modify as appropriate.
58 # Remove all files from previous tests
63 touch $SCRATCH_MNT/testf0
64 touch $SCRATCH_MNT/testf1
66 # {s,g}etfattr of "trusted.overlayxxx" should work.
67 # v4.3/6/7 v4.8-rc1 v4.8 v4.10
68 # setfattr ok not perm ok ok
69 # getfattr ok no attr ok ok
71 $SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
72 $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
74 _getfattr --absolute-names -n "trusted.overlayfsrz" \
75 $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
77 # {s,g}etfattr of "trusted.overlay.xxx" should fail.
78 # The errno returned varies among kernel versions,
79 # v4.3/7 v4.8-rc1 v4.8 v4.10
80 # setfattr not perm not perm not perm not supp
81 # getfattr no attr no attr not perm not supp
83 # Consider "Operation not {supported,permitted}" pass.
85 $SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
86 $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
87 sed -e 's/permitted/supported/g'
89 _getfattr --absolute-names -n "trusted.overlay.fsz" \
90 $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
91 sed -e 's/permitted/supported/g'