Skip to content

Commit a6e3e6f

Browse files
committed
Merge tag 'mm-nonmm-stable-2022-12-17-20-32' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull fault-injection updates from Andrew Morton: "Some fault-injection improvements from Wei Yongjun which enable stacktrace filtering on x86_64" * tag 'mm-nonmm-stable-2022-12-17-20-32' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: fault-injection: make stacktrace filter works as expected fault-injection: make some stack filter attrs more readable fault-injection: skip stacktrace filtering by default fault-injection: allow stacktrace filter for x86-64
2 parents 1ea9d33 + f9eeef5 commit a6e3e6f

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lib/Kconfig.debug

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,6 @@ config FAIL_SUNRPC
19831983
config FAULT_INJECTION_STACKTRACE_FILTER
19841984
bool "stacktrace filter for fault-injection capabilities"
19851985
depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT
1986-
depends on !X86_64
19871986
select STACKTRACE
19881987
depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86
19891988
help

lib/fault-inject.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static bool fail_stacktrace(struct fault_attr *attr)
7171
int n, nr_entries;
7272
bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX);
7373

74-
if (depth == 0)
74+
if (depth == 0 || (found && !attr->reject_start && !attr->reject_end))
7575
return found;
7676

7777
nr_entries = stack_trace_save(entries, depth, 1);
@@ -102,10 +102,16 @@ static inline bool fail_stacktrace(struct fault_attr *attr)
102102

103103
bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags)
104104
{
105+
bool stack_checked = false;
106+
105107
if (in_task()) {
106108
unsigned int fail_nth = READ_ONCE(current->fail_nth);
107109

108110
if (fail_nth) {
111+
if (!fail_stacktrace(attr))
112+
return false;
113+
114+
stack_checked = true;
109115
fail_nth--;
110116
WRITE_ONCE(current->fail_nth, fail_nth);
111117
if (!fail_nth)
@@ -125,6 +131,9 @@ bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags)
125131
if (atomic_read(&attr->times) == 0)
126132
return false;
127133

134+
if (!stack_checked && !fail_stacktrace(attr))
135+
return false;
136+
128137
if (atomic_read(&attr->space) > size) {
129138
atomic_sub(size, &attr->space);
130139
return false;
@@ -139,9 +148,6 @@ bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags)
139148
if (attr->probability <= get_random_u32_below(100))
140149
return false;
141150

142-
if (!fail_stacktrace(attr))
143-
return false;
144-
145151
fail:
146152
if (!(flags & FAULT_NOWARN))
147153
fail_dump(attr);
@@ -226,10 +232,10 @@ struct dentry *fault_create_debugfs_attr(const char *name,
226232
#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
227233
debugfs_create_stacktrace_depth("stacktrace-depth", mode, dir,
228234
&attr->stacktrace_depth);
229-
debugfs_create_ul("require-start", mode, dir, &attr->require_start);
230-
debugfs_create_ul("require-end", mode, dir, &attr->require_end);
231-
debugfs_create_ul("reject-start", mode, dir, &attr->reject_start);
232-
debugfs_create_ul("reject-end", mode, dir, &attr->reject_end);
235+
debugfs_create_xul("require-start", mode, dir, &attr->require_start);
236+
debugfs_create_xul("require-end", mode, dir, &attr->require_end);
237+
debugfs_create_xul("reject-start", mode, dir, &attr->reject_start);
238+
debugfs_create_xul("reject-end", mode, dir, &attr->reject_end);
233239
#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
234240

235241
attr->dname = dget(dir);

0 commit comments

Comments
 (0)