[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160617123841.21b1a7e1@gandalf.local.home>
Date: Fri, 17 Jun 2016 12:38:41 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: zhengjun.xing@...el.com
Cc: mingo@...hat.com, linux-kernel@...r.kernel.org,
Namhyung Kim <namhyung@...nel.org>
Subject: Re: [PATCH] tracing: Add *iter check for NULL
On Wed, 1 Jun 2016 16:31:10 +0800
zhengjun.xing@...el.com wrote:
> From: xingzhen <zhengjun.xing@...el.com>
>
> 3debb0a9ddb adding a "__used" to the variable in the
> __trace_printk_fmt section. Sometimes it will cause
> *iter to be NULL, then strcmp in lookup_format and
> strcpy in hold_module_trace_bprintk_format will panic.
Could you show an example of this happening?
>
> Signed-off-by: xingzhen <zhengjun.xing@...el.com>
> ---
> kernel/trace/trace_printk.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
> index f96f038..82ecfb5 100644
> --- a/kernel/trace/trace_printk.c
> +++ b/kernel/trace/trace_printk.c
> @@ -55,6 +55,8 @@ void hold_module_trace_bprintk_format(const char **start, const char **end)
>
> mutex_lock(&btrace_mutex);
> for (iter = start; iter < end; iter++) {
> + if (!*iter)
> + goto err;
> struct trace_bprintk_fmt *tb_fmt = lookup_format(*iter);
First, you can't place logic before a declaration. Not all compilers
will allow that.
Also, do we really want to error on this or just skip it? Because it
will miss out on all other trace_printks in the module.
-- Steve
> if (tb_fmt) {
> *iter = tb_fmt->fmt;
> @@ -75,6 +77,7 @@ void hold_module_trace_bprintk_format(const char **start, const char **end)
> *iter = fmt;
>
> }
> +err:
> mutex_unlock(&btrace_mutex);
> }
>
Powered by blists - more mailing lists