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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250924041125.268a4ceb@batman.local.home>
Date: Wed, 24 Sep 2025 04:11:25 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Michal Koutný <mkoutny@...e.com>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org, Masami
 Hiramatsu <mhiramat@...nel.org>, Mathieu Desnoyers
 <mathieu.desnoyers@...icios.com>
Subject: Re: [PATCH] tracing: Ensure optimized hashing works

On Tue, 23 Sep 2025 18:59:07 +0200
Michal Koutný <mkoutny@...e.com> wrote:

> If ever PID_MAX_DEFAULT changes, it must be compatible with tracing
> hashmaps assumptions.
> 
> Link: https://lore.kernel.org/r/20240409110126.651e94cb@gandalf.local.home/
> Signed-off-by: Michal Koutný <mkoutny@...e.com>
> ---
>  kernel/trace/trace_sched_switch.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> Drive-by flushing an old idea. Take it or leave it.
> 
> diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
> index cb49f7279dc80..aabae7daaac91 100644
> --- a/kernel/trace/trace_sched_switch.c
> +++ b/kernel/trace/trace_sched_switch.c
> @@ -243,6 +243,8 @@ int trace_create_savedcmd(void)
>  int trace_save_cmdline(struct task_struct *tsk)
>  {
>  	unsigned tpid, idx;
> +	/* so that map_pid_to_cmdline indexing is efficient */
> +	BUILD_BUG_ON(!is_power_of_2(PID_MAX_DEFAULT));

Please move this to just above the test. And it doesn't need a comment,
as it's obvious for why it needs to be a power of two when it's above
the test.

>  
>  	/* treat recording of idle task as a success */
>  	if (!tsk->pid)

Like this:

	/* treat recording of idle task as a success */
	if (!tsk->pid)
		return 1;

+	BUILD_BUG_ON(!is_power_of_2(PID_MAX_DEFAULT));
+
	tpid = tsk->pid & (PID_MAX_DEFAULT - 1);

-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ