generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 573
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright 2018 Google LLC
4 #
5 # FS QA Test generic/573
6 #
7 # Test access controls on the fs-verity ioctls.  FS_IOC_MEASURE_VERITY is
8 # allowed on any file, whereas FS_IOC_ENABLE_VERITY requires write access.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick verity
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16         cd /
17         _restore_fsverity_signatures
18         rm -f $tmp.*
19 }
20
21 # Import common functions.
22 . ./common/filter
23 . ./common/verity
24
25 # real QA test starts here
26 _supported_fs generic
27 _require_scratch_verity
28 _require_user
29 _require_chattr ia
30 _disable_fsverity_signatures
31
32 _scratch_mkfs_verity &>> $seqres.full
33 _scratch_mount
34 fsv_file=$SCRATCH_MNT/file.fsv
35
36 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY doesn't require root"
37 echo foo > $fsv_file
38 chmod 666 $fsv_file
39 _user_do "$FSVERITY_PROG enable $fsv_file"
40
41 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires write access"
42 echo foo > $fsv_file >> $seqres.full
43 chmod 444 $fsv_file
44 _user_do "$FSVERITY_PROG enable $fsv_file" |& _filter_scratch
45
46 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires !append-only"
47 echo foo > $fsv_file >> $seqres.full
48 $CHATTR_PROG +a $fsv_file
49 $FSVERITY_PROG enable $fsv_file |& _filter_scratch
50 $CHATTR_PROG -a $fsv_file
51
52 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires !immutable"
53 echo foo > $fsv_file >> $seqres.full
54 $CHATTR_PROG +i $fsv_file
55 $FSVERITY_PROG enable $fsv_file |& _filter_scratch
56 $CHATTR_PROG -i $fsv_file
57
58 _fsv_scratch_begin_subtest "FS_IOC_MEASURE_VERITY doesn't require root"
59 _fsv_create_enable_file $fsv_file >> $seqres.full
60 chmod 444 $fsv_file
61 su $qa_user -c "$FSVERITY_PROG measure $fsv_file" >> $seqres.full
62
63 # success, all done
64 status=0
65 exit