2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc. All Rights Reserved.
7 # Regression test for an XFS NULL xattr buffer problem during unlink. XFS had a
8 # bug where the attr fork walk during file removal could go off the rails due to
9 # a stale reference to content of a released buffer. Memory pressure could cause
10 # this reference to point to free or reused memory and cause subsequent
11 # attribute fork lookups to fail, return a NULL buffer and possibly crash.
13 # This test emulates this behavior using an error injection knob to explicitly
14 # disable buffer LRU caching. This forces the attr walk to execute under
15 # conditions where each buffer is immediately freed on release.
17 # Commit f35c5e10c6ed ("xfs: reinit btree pointer on attr tree inactivation
18 # walk") fixed the bug.
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
26 status=1 # failure is the default!
27 trap "_cleanup; exit \$status" 0 1 2 3 15
35 # get standard environment, filters and checks
40 # remove previous $seqres.full before test
43 # real QA test starts here
45 # Modify as appropriate.
48 _require_xfs_io_error_injection buf_lru_ref
52 _scratch_mkfs > $seqres.full 2>&1
55 file=$SCRATCH_MNT/testfile
57 # create a bunch of xattrs to form a multi-level attr tree
59 for i in $(seq 0 499); do
60 $SETFATTR_PROG -n trusted.user.$i -v 0 $file
63 # cycle the mount to clear any buffer references
64 _scratch_cycle_mount || _fail "cycle mount failure"
66 # disable the lru cache and unlink the file
67 _scratch_inject_error buf_lru_ref 1
69 _scratch_inject_error buf_lru_ref 0
71 echo Silence is golden