Skip to content

Commit 33c24be

Browse files
keesmcgrof
authored andcommitted
kallsyms: Add more debug output for selftest
While debugging a recent kallsyms_selftest failure[1], I needed more details on what specifically was failing. This adds those details for each failure state that is checked. [1] https://lore.kernel.org/all/202308232200.1c932a90-oliver.sang@intel.com/ Cc: Luis Chamberlain <mcgrof@kernel.org> Cc: Yonghong Song <yhs@meta.com> Cc: "Erhard F." <erhard_f@mailbox.org> Cc: Zhen Lei <thunder.leizhen@huawei.com> Cc: kernel test robot <oliver.sang@intel.com> Cc: Petr Mladek <pmladek@suse.com> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Yang Li <yang.lee@linux.alibaba.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent a684623 commit 33c24be

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

kernel/kallsyms_selftest.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ static int test_kallsyms_basic_function(void)
341341
ret = lookup_symbol_name(addr, namebuf);
342342
if (unlikely(ret)) {
343343
namebuf[0] = 0;
344+
pr_info("%d: lookup_symbol_name(%lx) failed\n", i, addr);
344345
goto failed;
345346
}
346347

@@ -388,8 +389,11 @@ static int test_kallsyms_basic_function(void)
388389
if (stat->addr != stat2->addr ||
389390
stat->real_cnt != stat2->real_cnt ||
390391
memcmp(stat->addrs, stat2->addrs,
391-
stat->save_cnt * sizeof(stat->addrs[0])))
392+
stat->save_cnt * sizeof(stat->addrs[0]))) {
393+
pr_info("%s: mismatch between kallsyms_on_each_symbol() and kallsyms_on_each_match_symbol()\n",
394+
namebuf);
392395
goto failed;
396+
}
393397

394398
/*
395399
* The average of random increments is 128, that is, one of
@@ -400,15 +404,23 @@ static int test_kallsyms_basic_function(void)
400404
}
401405

402406
/* Need to be found at least once */
403-
if (!stat->real_cnt)
407+
if (!stat->real_cnt) {
408+
pr_info("%s: Never found\n", namebuf);
404409
goto failed;
410+
}
405411

406412
/*
407413
* kallsyms_lookup_name() returns the address of the first
408414
* symbol found and cannot be NULL.
409415
*/
410-
if (!lookup_addr || lookup_addr != stat->addrs[0])
416+
if (!lookup_addr) {
417+
pr_info("%s: NULL lookup_addr?!\n", namebuf);
418+
goto failed;
419+
}
420+
if (lookup_addr != stat->addrs[0]) {
421+
pr_info("%s: lookup_addr != stat->addrs[0]\n", namebuf);
411422
goto failed;
423+
}
412424

413425
/*
414426
* If the addresses of all matching symbols are recorded, the
@@ -420,8 +432,10 @@ static int test_kallsyms_basic_function(void)
420432
break;
421433
}
422434

423-
if (j == stat->save_cnt)
435+
if (j == stat->save_cnt) {
436+
pr_info("%s: j == save_cnt?!\n", namebuf);
424437
goto failed;
438+
}
425439
}
426440
}
427441

0 commit comments

Comments
 (0)