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 _begin_fstest auto attr quick
30 # Import common functions.
34 # real QA test starts here
36 # Modify as appropriate.
39 _require_attrs trusted
41 # Remove all files from previous tests
46 touch $SCRATCH_MNT/testf0
47 touch $SCRATCH_MNT/testf1
49 # {s,g}etfattr of "trusted.overlayxxx" should work.
50 # v4.3/6/7 v4.8-rc1 v4.8 v4.10
51 # setfattr ok not perm ok ok
52 # getfattr ok no attr ok ok
54 $SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
55 $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
57 _getfattr --absolute-names -n "trusted.overlayfsrz" \
58 $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
60 # {s,g}etfattr of "trusted.overlay.xxx" should fail.
61 # The errno returned varies among kernel versions,
62 # v4.3/7 v4.8-rc1 v4.8 v4.10
63 # setfattr not perm not perm not perm not supp
64 # getfattr no attr no attr not perm not supp
66 # Consider "Operation not {supported,permitted}" pass.
68 $SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
69 $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
70 sed -e 's/permitted/supported/g'
72 _getfattr --absolute-names -n "trusted.overlay.fsz" \
73 $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
74 sed -e 's/permitted/supported/g'