Skip to content

Commit cdb9b07

Browse files
melverpaulmckrcu
authored andcommitted
kcsan: Make reporting aware of KCSAN tests
Reporting hides KCSAN runtime functions in the stack trace, with filtering done based on function names. Currently this included all functions (or modules) that would match "kcsan_". Make the filter aware of KCSAN tests, which contain "kcsan_test", and are no longer skipped in the report. This is in preparation for adding a KCSAN test module. Signed-off-by: Marco Elver <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent f770ed1 commit cdb9b07

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

kernel/kcsan/report.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,32 @@ static const char *get_thread_desc(int task_id)
262262
static int get_stack_skipnr(const unsigned long stack_entries[], int num_entries)
263263
{
264264
char buf[64];
265-
int len;
266-
int skip = 0;
265+
char *cur;
266+
int len, skip;
267267

268-
for (; skip < num_entries; ++skip) {
268+
for (skip = 0; skip < num_entries; ++skip) {
269269
len = scnprintf(buf, sizeof(buf), "%ps", (void *)stack_entries[skip]);
270-
if (!strnstr(buf, "csan_", len) &&
271-
!strnstr(buf, "tsan_", len) &&
272-
!strnstr(buf, "_once_size", len))
273-
break;
270+
271+
/* Never show tsan_* or {read,write}_once_size. */
272+
if (strnstr(buf, "tsan_", len) ||
273+
strnstr(buf, "_once_size", len))
274+
continue;
275+
276+
cur = strnstr(buf, "kcsan_", len);
277+
if (cur) {
278+
cur += sizeof("kcsan_") - 1;
279+
if (strncmp(cur, "test", sizeof("test") - 1))
280+
continue; /* KCSAN runtime function. */
281+
/* KCSAN related test. */
282+
}
283+
284+
/*
285+
* No match for runtime functions -- @skip entries to skip to
286+
* get to first frame of interest.
287+
*/
288+
break;
274289
}
290+
275291
return skip;
276292
}
277293

0 commit comments

Comments
 (0)