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] [day] [month] [year] [list]
Message-ID: <20250819182130.75542133@gandalf.local.home>
Date: Tue, 19 Aug 2025 18:21:30 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Sasha Levin <sashal@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
 bpf@...r.kernel.org, Masami Hiramatsu <mhiramat@...nel.org>, Mark Rutland
 <mark.rutland@....com>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 Andrew Morton <akpm@...ux-foundation.org>, Sven Schnelle
 <svens@...ux.ibm.com>, Paul Walmsley <paul.walmsley@...ive.com>, Palmer
 Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>, Guo Ren
 <guoren@...nel.org>, Donglin Peng <dolinux.peng@...il.com>, Zheng Yejian
 <zhengyejian@...weicloud.com>
Subject: Re: [PATCH v4 2/4] ftrace: Add support for function argument to
 graph tracer

On Thu, 14 Aug 2025 13:05:35 -0400
Sasha Levin <sashal@...nel.org> wrote:

> On Wed, 
> Got a small build error:
> 
> kernel/trace/trace_functions_graph.c: In function ‘get_return_for_leaf’:
> ./include/linux/stddef.h:16:33: error: ‘struct fgraph_retaddr_ent_entry’ has no member named ‘args’
>     16 | #define offsetof(TYPE, MEMBER)  __builtin_offsetof(TYPE, MEMBER)
>        |                                 ^~~~~~~~~~~~~~~~~~
> kernel/trace/trace_functions_graph.c:640:40: note: in expansion of macro ‘offsetof’
>    640 |                                 size = offsetof(struct fgraph_retaddr_ent_entry, args);
>        |                                        ^~~~~~~~
> 
> Does this look right on top of your patch:

Bah, it was on the todo list to add args to retaddr. But it never was done.

> 
> diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> index 25ea71edb8da..f0f37356ef29 100644
> --- a/kernel/trace/trace_functions_graph.c
> +++ b/kernel/trace/trace_functions_graph.c
> @@ -637,20 +637,21 @@ get_return_for_leaf(struct trace_iterator *iter,
>                           */
>                          if (unlikely(curr->ent.type == TRACE_GRAPH_RETADDR_ENT)) {
>                                  data->ent.rent = *(struct fgraph_retaddr_ent_entry *)curr;
> -                               size = offsetof(struct fgraph_retaddr_ent_entry, args);
> +                               /* fgraph_retaddr_ent_entry doesn't have args field */

"doesn't have args field" yet!

> +                               size = sizeof(struct fgraph_retaddr_ent_entry);
> +                               args_size = 0;
>                          } else {
>                                  data->ent.ent = *curr;
>                                  size = offsetof(struct ftrace_graph_ent_entry, args);
> +                               /* If this has args, then append them to after the ent. */
> +                               args_size = iter->ent_size - size;
> +                               if (args_size > sizeof(long) * FTRACE_REGS_MAX_ARGS)
> +                                       args_size = sizeof(long) * FTRACE_REGS_MAX_ARGS;
> +
> +                               if (args_size >= sizeof(long))
> +                                       memcpy((void *)&data->ent.ent + size,
> +                                              (void*)curr + size, args_size);
>                          }

Here's a different update:

-- Steve


diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 66e1a527cf1a..a7f4b9a47a71 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -27,14 +27,21 @@ struct fgraph_cpu_data {
 	unsigned long	enter_funcs[FTRACE_RETFUNC_DEPTH];
 };
 
+struct fgraph_ent_args {
+	struct ftrace_graph_ent_entry	ent;
+	/* Force the sizeof of args[] to have FTRACE_REGS_MAX_ARGS entries */
+	unsigned long			args[FTRACE_REGS_MAX_ARGS];
+};
+
 struct fgraph_data {
 	struct fgraph_cpu_data __percpu *cpu_data;
 
 	/* Place to preserve last processed entry. */
 	union {
-		struct ftrace_graph_ent_entry	ent;
+		struct fgraph_ent_args		ent;
+		/* TODO allow retaddr to have args */
 		struct fgraph_retaddr_ent_entry	rent;
-	} ent;
+	};
 	struct ftrace_graph_ret_entry	ret;
 	int				failed;
 	int				cpu;
@@ -627,10 +634,13 @@ get_return_for_leaf(struct trace_iterator *iter,
 			 * Save current and next entries for later reference
 			 * if the output fails.
 			 */
-			if (unlikely(curr->ent.type == TRACE_GRAPH_RETADDR_ENT))
-				data->ent.rent = *(struct fgraph_retaddr_ent_entry *)curr;
-			else
-				data->ent.ent = *curr;
+			if (unlikely(curr->ent.type == TRACE_GRAPH_RETADDR_ENT)) {
+				data->rent = *(struct fgraph_retaddr_ent_entry *)curr;
+			} else {
+				int size = min((int)sizeof(data->ent), (int)iter->ent_size);
+
+				memcpy(&data->ent, curr, size);
+			}
 			/*
 			 * If the next event is not a return type, then
 			 * we only care about what type it is. Otherwise we can


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ