fault-injection: skip stacktrace filtering by default
authorWei Yongjun <weiyongjun1@huawei.com>
Wed, 17 Aug 2022 08:03:30 +0000 (08:03 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 16 Dec 2022 00:40:43 +0000 (16:40 -0800)
If FAULT_INJECTION_STACKTRACE_FILTER is enabled, the depth is default to
32.  This means fail_stacktrace() will iter each entry's stacktrace, even
if filter is not configured.

This patch changes to quick return from fail_stacktrace() if stacktrace
filter is not set.

Link: https://lkml.kernel.org/r/20220817080332.1052710-3-weiyongjun1@huawei.com
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Isabella Basso <isabbasso@riseup.net>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/fault-inject.c

index 1421818c9ef75eff0f31ab7ee2b3c8c24789d883..fecc4d8ca32ae3b74d3bcfa784eba87269a8f74a 100644 (file)
@@ -71,7 +71,7 @@ static bool fail_stacktrace(struct fault_attr *attr)
        int n, nr_entries;
        bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX);
 
-       if (depth == 0)
+       if (depth == 0 || (found && !attr->reject_start && !attr->reject_end))
                return found;
 
        nr_entries = stack_trace_save(entries, depth, 1);