generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 431
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Facebook, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 431
6 #
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.
11 #
12 # See CVE-2017-14340 for more information.
13 #
14 . ./common/preamble
15 _begin_fstest auto quick
16
17 # Import common functions.
18 . ./common/filter
19
20 # real QA test starts here
21
22 # Modify as appropriate.
23 _supported_fs xfs
24 _require_xfs_io_command "chattr" "t"
25 _require_xfs_io_command "fsync"
26 _require_xfs_io_command "pwrite"
27 _require_scratch
28
29 _scratch_mkfs >/dev/null 2>&1
30 _scratch_mount
31
32 # Set realtime inherit flag on scratch mount, suppress output
33 # as this may simply error out on future kernels
34 _xfs_force_bdev realtime $SCRATCH_MNT &> /dev/null
35
36 # Check if 't' is actually set, as xfs_io returns 0 even when it fails to set
37 # an attribute. And erroring out here is fine, this would be desired behavior
38 # for FSes without realtime devices present.
39 if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then
40         # Attempt to write/fsync data to file
41         $XFS_IO_PROG -fc 'pwrite 0 1m' -c fsync $SCRATCH_MNT/testfile |
42                 tee -a $seqres.full | _filter_xfs_io
43
44         # Remove the testfile and rt inherit flag after we are done or
45         # xfs_repair will fail.
46         rm -f $SCRATCH_MNT/testfile
47         _xfs_force_bdev data $SCRATCH_MNT | tee -a $seqres.full 2>&1
48 fi
49
50 # success, all done
51 status=0
52 exit