From: Petr Mladek <pmladek@suse.com>
To: Feng Tang <feng.tang@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Lance Yang <lance.yang@linux.dev>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, paulmck@kernel.org,
john.ogness@linutronix.de
Subject: Re: [PATCH 3/5] panic: add 'panic_sys_info' sysctl to take human readable string parameter
Date: Tue, 12 Aug 2025 12:23:07 +0200 [thread overview]
Message-ID: <aJsWCxc42f2Qjbs3@pathway> (raw)
In-Reply-To: <20250703021004.42328-4-feng.tang@linux.alibaba.com>
On Thu 2025-07-03 10:10:02, Feng Tang wrote:
> Bitmap definition for 'panic_print' is hard to remember and decode.
> Add 'panic_sys_info='sysctl to take human readable string like
> "tasks,mem,timers,locks,ftrace,..." and translate it into bitmap.
>
> The detailed mapping is:
> SYS_INFO_TASKS "tasks"
> SYS_INFO_MEM "mem"
> SYS_INFO_TIMERS "timers"
> SYS_INFO_LOCKS "locks"
> SYS_INFO_FTRACE "ftrace"
> SYS_INFO_ALL_CPU_BT "all_bt"
> SYS_INFO_BLOCKED_TASKS "blocked_tasks"
>
> --- a/lib/sys_info.c
> +++ b/lib/sys_info.c
> +static const char sys_info_avail[] = "tasks,mem,timers,locks,ftrace,all_bt,blocked_tasks";
> +
> +int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
> + void *buffer, size_t *lenp,
> + loff_t *ppos)
> +{
> + char names[sizeof(sys_info_avail) + 1];
The "+ 1" looks superfluous.
I guess that it is for the trailing '\0'. But sys_info_avail[] already
includes the trailing '\0' so it should be already counted by the sizeof().
Note that it would be needed with strlen(). But it should not be
needed with sizeof().
> + struct ctl_table table;
> + unsigned long *si_bits_global;
> +
> + si_bits_global = ro_table->data;
> +
> + if (write) {
> + unsigned long si_bits;
> + int ret;
> +
> + table = *ro_table;
> + table.data = names;
> + table.maxlen = sizeof(names);
> + ret = proc_dostring(&table, write, buffer, lenp, ppos);
> + if (ret)
> + return ret;
> +
> + si_bits = sys_info_parse_param(names);
> + /* The access to the global value is not synchronized. */
> + WRITE_ONCE(*si_bits_global, si_bits);
> + return 0;
> + } else {
> + /* for 'read' operation */
> + char *delim = "";
> + int i, len = 0;
> +
It looks to me that names[] can later be used non-initialized when
*si_bits_global == 0. We should initialized it here, something like:
names[0] = '\0';
> + for (i = 0; i < ARRAY_SIZE(si_names); i++) {
> + if (*si_bits_global & si_names[i].bit) {
> + len += scnprintf(names + len, sizeof(names) - len,
> + "%s%s", delim, si_names[i].name);
> + delim = ",";
> + }
> + }
> +
> + table = *ro_table;
> + table.data = names;
> + table.maxlen = sizeof(names);
> + return proc_dostring(&table, write, buffer, lenp, ppos);
> + }
> +}
> +#endif
Otherwise, it looks good.
Best Regards,
Petr
next prev parent reply other threads:[~2025-08-12 10:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 2:09 [PATCH v3 0/5] generalize panic_print's dump function to be used by other kernel parts Feng Tang
2025-07-03 2:10 ` [PATCH v3 1/5] panic: clean up code for console replay Feng Tang
2025-07-14 21:09 ` Askar Safin
2025-07-15 0:49 ` Feng Tang
2025-07-15 1:18 ` Askar Safin
2025-07-15 1:34 ` Feng Tang
2025-07-15 2:48 ` Askar Safin
2025-07-15 3:27 ` Feng Tang
2025-08-12 11:59 ` Petr Mladek
2025-08-13 0:43 ` Feng Tang
2025-07-03 2:10 ` [PATCH v3 2/5] panic: generalize panic_print's function to show sys info Feng Tang
2025-08-12 10:12 ` Petr Mladek
2025-07-03 2:10 ` [PATCH 3/5] panic: add 'panic_sys_info' sysctl to take human readable string parameter Feng Tang
2025-07-03 2:56 ` Lance Yang
2025-07-03 3:18 ` Feng Tang
2025-08-12 10:23 ` Petr Mladek [this message]
2025-08-13 0:39 ` Feng Tang
2025-07-03 2:10 ` [PATCH v3 4/5] panic: add 'panic_sys_info=' setup option for kernel cmdline Feng Tang
2025-08-12 10:31 ` Petr Mladek
2025-07-03 2:10 ` [PATCH v3 5/5] panic: add note that panic_print sysctl interface is deprecated Feng Tang
2025-08-12 11:52 ` Petr Mladek
2025-08-13 1:05 ` Feng Tang
2025-08-14 15:21 ` Petr Mladek
2025-07-03 3:23 ` [PATCH v3 0/5] generalize panic_print's dump function to be used by other kernel parts Lance Yang
2025-07-03 4:56 ` Lance Yang
2025-07-03 5:54 ` Feng Tang
-- strict thread matches above, loose matches on Subject: below --
2025-07-09 2:29 [PATCH 3/5] panic: add 'panic_sys_info' sysctl to take human readable string parameter Sergey Senozhatsky
2025-07-09 3:27 ` Feng Tang
2025-07-09 3:35 ` Sergey Senozhatsky
2025-07-09 3:58 ` Feng Tang
2025-07-10 3:27 ` Sergey Senozhatsky
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=aJsWCxc42f2Qjbs3@pathway \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=feng.tang@linux.alibaba.com \
--cc=john.ogness@linutronix.de \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.