lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241101105102.eb308ab85b2b13d03444d4bf@kernel.org>
Date: Fri, 1 Nov 2024 10:51:02 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Alexei Starovoitov <alexei.starovoitov@...il.com>, Florent Revest
 <revest@...omium.org>, linux-trace-kernel@...r.kernel.org, LKML
 <linux-kernel@...r.kernel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
 bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>, Jiri Olsa
 <jolsa@...nel.org>, Alan Maguire <alan.maguire@...cle.com>, Mark Rutland
 <mark.rutland@....com>, linux-arch@...r.kernel.org, Catalin Marinas
 <catalin.marinas@....com>, Will Deacon <will@...nel.org>, Huacai Chen
 <chenhuacai@...nel.org>, WANG Xuerui <kernel@...0n.name>, Michael Ellerman
 <mpe@...erman.id.au>, Nicholas Piggin <npiggin@...il.com>, Christophe Leroy
 <christophe.leroy@...roup.eu>, Naveen N Rao <naveen@...nel.org>, Madhavan
 Srinivasan <maddy@...ux.ibm.com>, Paul Walmsley <paul.walmsley@...ive.com>,
 Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
 Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>, Mathieu Desnoyers
 <mathieu.desnoyers@...icios.com>
Subject: Re: [PATCH v18 01/17] fgraph: Pass ftrace_regs to entryfunc

On Thu, 31 Oct 2024 15:53:24 -0400
Steven Rostedt <rostedt@...dmis.org> wrote:

> On Sat, 26 Oct 2024 13:35:30 +0900
> "Masami Hiramatsu (Google)" <mhiramat@...nel.org> wrote:
> 
> > From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
> > 
> > Pass ftrace_regs to the fgraph_ops::entryfunc(). If ftrace_regs is not
> > available, it passes a NULL instead. User callback function can access
> > some registers (including return address) via this ftrace_regs.
> > 
> > Note that the ftrace_regs can be NULL when the arch does NOT define:
> > HAVE_DYNAMIC_FTRACE_WITH_ARGS or HAVE_DYNAMIC_FTRACE_WITH_REGS.
> > More specifically, if HAVE_DYNAMIC_FTRACE_WITH_REGS is defined but
> > not the HAVE_DYNAMIC_FTRACE_WITH_ARGS, and the ftrace ops used to
> > register the function callback does not set FTRACE_OPS_FL_SAVE_REGS.
> > In this case, ftrace_regs can be NULL in user callback.
> 
> If HAVE_DYNAMIC_FTRACE_WITH_REGS is defined but not
> HAVE_DYNAMIC_FTRACE_WITH_ARGS is not, then the callback will have regs defined.
> 
> > @@ -977,7 +980,7 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
> >  
> >  static struct ftrace_ops graph_ops = {
> >  	.func			= ftrace_graph_func,
> > -	.flags			= FTRACE_OPS_GRAPH_STUB,
> > +	.flags			= FTRACE_OPS_GRAPH_STUB | FTRACE_OPS_FL_SAVE_ARGS,
> 
> Enabling FTRACE_OPS_FL_SAVE_ARGS will pass full regs in that case. Are you
> just saying in the change log that this is what you did? As it currently
> reads, it sounds like a fgraph user needs to add FTRACE_OPS_FL_SAVE_REGS??

Ah, good catch! It should put the flag only when HAVE_DYNAMIC_FTRACE_WITH_ARGS
is enabled.

static struct ftrace_ops graph_ops = {
	.func			= ftrace_graph_func,
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
	.flags			= FTRACE_OPS_GRAPH_STUB | FTRACE_OPS_FL_SAVE_ARGS,
#elif defined(CONFIG_DYNAMIC_FTRACE_WITH_ARGS)
	.flags			= FTRACE_OPS_GRAPH_STUB | FTRACE_OPS_FL_SAVE_REGS,
#else
	.flags			= FTRACE_OPS_GRAPH_STUB,
#endif

This will save fregs or regs or NULL according to the configuration.

> 
> -- Steve
> 
> 
> >  #ifdef FTRACE_GRAPH_TRAMP_ADDR
> >  	.trampoline		= FTRACE_GRAPH_TRAMP_ADDR,
> >  	/* trampoline_size is only needed for dynamically allocated tramps */
> > @@ -987,7 +990,8 @@ static struct ftrace_ops graph_ops = {
> >  void fgraph_init_ops(struct ftrace_ops *dst_ops,
> >  		     struct ftrace_ops *src_ops)
> >  {
> > -	dst_ops->flags = FTRACE_OPS_FL_PID | FTRACE_OPS_GRAPH_STUB;
> > +	dst_ops->flags = FTRACE_OPS_FL_PID | FTRACE_OPS_GRAPH_STUB |
> > +			 FTRACE_OPS_FL_SAVE_ARGS;
> >  
> >  #ifdef CONFIG_DYNAMIC_FTRACE
> >  	if (src_ops) {


-- 
Masami Hiramatsu (Google) <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ