4 # Regression test for an XFS NULL xattr buffer problem during unlink. XFS had a
5 # bug where the attr fork walk during file removal could go off the rails due to
6 # a stale reference to content of a released buffer. Memory pressure could cause
7 # this reference to point to free or reused memory and cause subsequent
8 # attribute fork lookups to fail, return a NULL buffer and possibly crash.
10 # This test emulates this behavior using an error injection knob to explicitly
11 # disable buffer LRU caching. This forces the attr walk to execute under
12 # conditions where each buffer is immediately freed on release.
14 # Commit f35c5e10c6ed ("xfs: reinit btree pointer on attr tree inactivation
15 # walk") fixed the bug.
17 #-----------------------------------------------------------------------
18 # Copyright (c) 2017 Red Hat, Inc. All Rights Reserved.
20 # This program is free software; you can redistribute it and/or
21 # modify it under the terms of the GNU General Public License as
22 # published by the Free Software Foundation.
24 # This program is distributed in the hope that it would be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 # GNU General Public License for more details.
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write the Free Software Foundation,
31 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #-----------------------------------------------------------------------
36 seqres=$RESULT_DIR/$seq
37 echo "QA output created by $seq"
41 status=1 # failure is the default!
42 trap "_cleanup; exit \$status" 0 1 2 3 15
50 # get standard environment, filters and checks
55 # remove previous $seqres.full before test
58 # real QA test starts here
60 # Modify as appropriate.
63 _require_xfs_io_error_injection buf_lru_ref
67 _scratch_mkfs > $seqres.full 2>&1
70 file=$SCRATCH_MNT/testfile
72 # create a bunch of xattrs to form a multi-level attr tree
74 for i in $(seq 0 499); do
75 $SETFATTR_PROG -n trusted.user.$i -v 0 $file
78 # cycle the mount to clear any buffer references
79 _scratch_cycle_mount || _fail "cycle mount failure"
81 # disable the lru cache and unlink the file
82 _scratch_inject_error buf_lru_ref 1
84 _scratch_inject_error buf_lru_ref 0
86 echo Silence is golden