[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241030194006.4d29417c@rorschach.local.home>
Date: Wed, 30 Oct 2024 19:40:06 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Jinjie Ruan <ruanjinjie@...wei.com>
Cc: <mhiramat@...nel.org>, <mathieu.desnoyers@...icios.com>,
<linux-kernel@...r.kernel.org>, <linux-trace-kernel@...r.kernel.org>
Subject: Re: [PATCH] tracing: Replace strncpy() with strscpy() when copying
comm
On Wed, 31 Jul 2024 15:50:58 +0800
Jinjie Ruan <ruanjinjie@...wei.com> wrote:
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 6ece1308d36a..4ee0e64719fa 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -1599,7 +1599,7 @@ static inline void save_comm(char *comm, struct task_struct *task)
> return;
> }
>
> - strncpy(comm, task->comm, TASK_COMM_LEN);
> + strscpy(comm, task->comm);
> }
>
Was this even compiled?
In file included from /work/git/test-linux.git/include/linux/container_of.h:5,
from /work/git/test-linux.git/include/linux/list.h:5,
from /work/git/test-linux.git/include/linux/module.h:12,
from /work/git/test-linux.git/kernel/trace/trace_events_hist.c:8:
/work/git/test-linux.git/kernel/trace/trace_events_hist.c: In function ‘save_comm’:
/work/git/test-linux.git/include/linux/build_bug.h:16:51: error: negative width in bit-field ‘<anonymous>’
16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
| ^
/work/git/test-linux.git/include/linux/compiler.h:243:33: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
243 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
| ^~~~~~~~~~~~~~~~~
/work/git/test-linux.git/include/linux/string.h:79:47: note: in expansion of macro ‘__must_be_array’
79 | sized_strscpy(dst, src, sizeof(dst) + __must_be_array(dst) + \
| ^~~~~~~~~~~~~~~
/work/git/test-linux.git/include/linux/args.h:25:24: note: in expansion of macro ‘__strscpy0’
25 | #define __CONCAT(a, b) a ## b
| ^
/work/git/test-linux.git/include/linux/args.h:26:27: note: in expansion of macro ‘__CONCAT’
26 | #define CONCATENATE(a, b) __CONCAT(a, b)
| ^~~~~~~~
/work/git/test-linux.git/include/linux/string.h:113:9: note: in expansion of macro ‘CONCATENATE’
113 | CONCATENATE(__strscpy, COUNT_ARGS(__VA_ARGS__))(dst, src, __VA_ARGS__)
| ^~~~~~~~~~~
/work/git/test-linux.git/kernel/trace/trace_events_hist.c:1602:9: note: in expansion of macro ‘strscpy’
1602 | strscpy(comm, task->comm);
| ^~~~~~~
Bah!
-- Steve
Powered by blists - more mailing lists