2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Facebook, Inc. All Rights Reserved.
7 # Verify kernel doesn't panic when user attempts to set realtime flags
8 # on non-realtime FS, using kernel compiled with CONFIG_XFS_RT. Unpatched
9 # kernels will panic during this test. Kernels not compiled with
10 # CONFIG_XFS_RT should pass test.
12 # See CVE-2017-14340 for more information.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
33 # remove previous $seqres.full before test
36 # real QA test starts here
38 # Modify as appropriate.
41 _require_xfs_io_command "chattr"
42 _require_xfs_io_command "fsync"
43 _require_xfs_io_command "pwrite"
46 _scratch_mkfs >/dev/null 2>&1
49 # Set realtime inherit flag on scratch mount, suppress output
50 # as this may simply error out on future kernels
51 $XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT &> /dev/null
53 # Check if 't' is actually set, as xfs_io returns 0 even when it fails to set
54 # an attribute. And erroring out here is fine, this would be desired behavior
55 # for FSes without realtime devices present.
56 if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then
57 # Attempt to write/fsync data to file
58 $XFS_IO_PROG -fc 'pwrite 0 1m' -c fsync $SCRATCH_MNT/testfile |
59 tee -a $seqres.full | _filter_xfs_io
61 # Remove the testfile and rt inherit flag after we are done or
62 # xfs_repair will fail.
63 rm -f $SCRATCH_MNT/testfile
64 $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT | tee -a $seqres.full 2>&1