From: Petr Mladek <pmladek@suse.com>
To: Stephen Boyd <swboyd@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
Alexei Starovoitov <ast@kernel.org>, Jessica Yu <jeyu@kernel.org>,
Evan Green <evgreen@chromium.org>,
Hsin-Yi Wang <hsinyi@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-doc@vger.kernel.org, Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v2 04/12] module: Add printk format to add module build ID to stacktraces
Date: Tue, 30 Mar 2021 12:29:24 +0200 [thread overview]
Message-ID: <YGL9hHFg9Pm4xaNM@alley> (raw)
In-Reply-To: <20210324020443.1815557-5-swboyd@chromium.org>
On Tue 2021-03-23 19:04:35, Stephen Boyd wrote:
> Let's make kernel stacktraces easier to identify by including the build
> ID[1] of a module if the stacktrace is printing a symbol from a module.
>
> Example:
>
> WARNING: CPU: 3 PID: 3373 at drivers/misc/lkdtm/bugs.c:83 lkdtm_WARNING+0x28/0x30 [lkdtm]
> Modules linked in: lkdtm rfcomm algif_hash algif_skcipher af_alg xt_cgroup uinput xt_MASQUERADE hci_uart <modules trimmed>
> CPU: 3 PID: 3373 Comm: bash Not tainted 5.11 #12 a8c0d47f7051f3e6670ceaea724af66a39c6cec8
I tested it with "echo l >/proc/sysrq-trigger" and I got the following
output:
[ 71.905593] CPU: 0 PID: 1762 Comm: bash Kdump: loaded Not tainted 5.12.0-rc5-default+ #167 00000080ffffffff0000000000000000
00000000
It does not looks like an unique build-id.
Any idea what was going wrong?
> --- a/include/linux/kallsyms.h
> +++ b/include/linux/kallsyms.h
> @@ -91,6 +93,7 @@ const char *kallsyms_lookup(unsigned long addr,
>
> /* Look up a kernel symbol and return it in a text buffer. */
> extern int sprint_symbol(char *buffer, unsigned long address);
> +extern int sprint_symbol_stacktrace(char *buffer, unsigned long address);
> extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
> extern int sprint_backtrace(char *buffer, unsigned long address);
Could we use a more clear name? It is hard to guess what is
the difference between sprint_*_stacktrace() and sprint_backtrace().
What about sprint_symbol_build_id() ?
> diff --git a/kernel/module.c b/kernel/module.c
> index 30479355ab85..9e9cb502fb33 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -2770,6 +2771,20 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
> }
> mod->core_kallsyms.num_symtab = ndst;
> }
> +
> +static void init_build_id(struct module *mod, const struct load_info *info)
> +{
> + const Elf_Shdr *sechdr;
> + unsigned int i;
> +
> + for (i = 0; i < info->hdr->e_shnum; i++) {
> + sechdr = &info->sechdrs[i];
> + if (!sect_empty(sechdr) && sechdr->sh_type == SHT_NOTE &&
> + !build_id_parse_buf((void *)sechdr->sh_addr, mod->build_id,
> + sechdr->sh_size))
> + break;
> + }
Just to be sure. Is this really reliable way how to find the build ID,
please?
> +}
> #else
> static inline void layout_symtab(struct module *mod, struct load_info *info)
> {
> @@ -2778,6 +2793,10 @@ static inline void layout_symtab(struct module *mod, struct load_info *info)
> static void add_kallsyms(struct module *mod, const struct load_info *info)
> {
> }
Best Regards,
Petr
next prev parent reply other threads:[~2021-03-30 10:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-24 2:04 [PATCH v2 00/12] Add build ID to stacktraces Stephen Boyd
2021-03-24 2:04 ` [PATCH v2 04/12] module: Add printk format to add module " Stephen Boyd
2021-03-24 9:57 ` Rasmus Villemoes
2021-03-24 19:11 ` Stephen Boyd
2021-03-24 22:21 ` Rasmus Villemoes
2021-03-24 22:28 ` Stephen Boyd
2021-03-30 10:51 ` Petr Mladek
2021-03-30 10:29 ` Petr Mladek [this message]
2021-03-30 19:12 ` Stephen Boyd
2021-03-24 8:55 ` [PATCH v2 00/12] Add " Christoph Hellwig
2021-03-25 11:06 ` peter enderborg
2021-03-25 23:21 ` Stephen Boyd
2021-03-30 10:59 ` Petr Mladek
[not found] ` <32011616573677@mail.yandex-team.ru>
2021-03-24 19:04 ` Stephen Boyd
2021-03-25 11:14 ` peter enderborg
2021-03-25 23:18 ` Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YGL9hHFg9Pm4xaNM@alley \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ast@kernel.org \
--cc=evgreen@chromium.org \
--cc=hsinyi@chromium.org \
--cc=jeyu@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=swboyd@chromium.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox