[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240102101712.515e0fe3@gandalf.local.home>
Date: Tue, 2 Jan 2024 10:17:12 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Ilya Leoshkevich <iii@...ux.ibm.com>
Cc: Alexander Gordeev <agordeev@...ux.ibm.com>, Alexander Potapenko
<glider@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>, Christoph
Lameter <cl@...ux.com>, David Rientjes <rientjes@...gle.com>, Heiko
Carstens <hca@...ux.ibm.com>, Joonsoo Kim <iamjoonsoo.kim@....com>, Marco
Elver <elver@...gle.com>, Masami Hiramatsu <mhiramat@...nel.org>, Pekka
Enberg <penberg@...nel.org>, Vasily Gorbik <gor@...ux.ibm.com>, Vlastimil
Babka <vbabka@...e.cz>, Christian Borntraeger <borntraeger@...ux.ibm.com>,
Dmitry Vyukov <dvyukov@...gle.com>, Hyeonggon Yoo <42.hyeyoo@...il.com>,
kasan-dev@...glegroups.com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-s390@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, Mark Rutland <mark.rutland@....com>,
Roman Gushchin <roman.gushchin@...ux.dev>, Sven Schnelle
<svens@...ux.ibm.com>
Subject: Re: [PATCH v3 01/34] ftrace: Unpoison ftrace_regs in
ftrace_ops_list_func()
On Thu, 14 Dec 2023 00:24:21 +0100
Ilya Leoshkevich <iii@...ux.ibm.com> wrote:
> Architectures use assembly code to initialize ftrace_regs and call
> ftrace_ops_list_func(). Therefore, from the KMSAN's point of view,
> ftrace_regs is poisoned on ftrace_ops_list_func entry(). This causes
> KMSAN warnings when running the ftrace testsuite.
BTW, why is this only a problem for s390 and no other architectures?
If it is only a s390 thing, then we should do this instead:
in include/linux/ftrace.h:
/* Add a comment here to why this is needed */
#ifndef ftrace_list_func_unpoison
# define ftrace_list_func_unpoison(fregs) do { } while(0)
#endif
In arch/s390/include/asm/ftrace.h:
/* Add a comment to why s390 is special */
# define ftrace_list_func_unpoison(fregs) kmsan_unpoison_memory(fregs, sizeof(*fregs))
>
> Fix by trusting the architecture-specific assembly code and always
> unpoisoning ftrace_regs in ftrace_ops_list_func.
>
> Acked-by: Steven Rostedt (Google) <rostedt@...dmis.org>
I'm taking my ack away for this change in favor of what I'm suggesting now.
> Reviewed-by: Alexander Potapenko <glider@...gle.com>
> Signed-off-by: Ilya Leoshkevich <iii@...ux.ibm.com>
> ---
> kernel/trace/ftrace.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 8de8bec5f366..dfb8b26966aa 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -7399,6 +7399,7 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
> void arch_ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
> struct ftrace_ops *op, struct ftrace_regs *fregs)
> {
> + kmsan_unpoison_memory(fregs, sizeof(*fregs));
And here have:
ftrace_list_func_unpoison(fregs);
That way we only do it for archs that really need it, and do not affect
archs that do not.
I want to know why this only affects s390, because if we are just doing
this because "it works", it could be just covering up a symptom of
something else and not actually doing the "right thing".
-- Steve
> __ftrace_ops_list_func(ip, parent_ip, NULL, fregs);
> }
> #else
Powered by blists - more mailing lists