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.
55 _require_attrs trusted
57 # Remove all files from previous tests
62 touch $SCRATCH_MNT/testf0
63 touch $SCRATCH_MNT/testf1
65 # {s,g}etfattr of "trusted.overlayxxx" should work.
66 # v4.3/6/7 v4.8-rc1 v4.8 v4.10
67 # setfattr ok not perm ok ok
68 # getfattr ok no attr ok ok
70 $SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
71 $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
73 _getfattr --absolute-names -n "trusted.overlayfsrz" \
74 $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
76 # {s,g}etfattr of "trusted.overlay.xxx" should fail.
77 # The errno returned varies among kernel versions,
78 # v4.3/7 v4.8-rc1 v4.8 v4.10
79 # setfattr not perm not perm not perm not supp
80 # getfattr no attr no attr not perm not supp
82 # Consider "Operation not {supported,permitted}" pass.
84 $SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
85 $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
86 sed -e 's/permitted/supported/g'
88 _getfattr --absolute-names -n "trusted.overlay.fsz" \
89 $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
90 sed -e 's/permitted/supported/g'