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: <20250819204709.556e9f54@gandalf.local.home>
Date: Tue, 19 Aug 2025 20:47:09 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Tengda Wu <wutengda@...weicloud.com>
Cc: Masami Hiramatsu <mhiramat@...nel.org>, Mark Rutland
 <mark.rutland@....com>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 linux-trace-kernel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH -next 1/2] ftrace: Remove unnecessary free_ftrace_hash
 in ftrace_regex_open

On Wed, 13 Aug 2025 02:30:43 +0000
Tengda Wu <wutengda@...weicloud.com> wrote:


> The free_ftrace_hash call is just unnecessary in this context since
> we shouldn't free the global hash that we don't own. Remove this call
> to fix the issue.

This is incorrect as it is only unnecessary if it's a read.

The code above is:

	if (file->f_mode & FMODE_WRITE) {
		const int size_bits = FTRACE_HASH_DEFAULT_BITS;

		if (file->f_flags & O_TRUNC) {
			iter->hash = alloc_ftrace_hash(size_bits);
			clear_ftrace_mod_list(mod_head);
	        } else {
			iter->hash = alloc_and_copy_ftrace_hash(size_bits, hash);
		}

		if (!iter->hash) {
			trace_parser_put(&iter->parser);
			goto out_unlock;
		}
	} else
		iter->hash = hash;

Where if the file was open for write, the hash must be freed.


> 
> Fixes: c20489dad156 ("ftrace: Assign iter->hash to filter or notrace hashes on seq read")


> Signed-off-by: Tengda Wu <wutengda@...weicloud.com>
> ---
>  kernel/trace/ftrace.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 00b76d450a89..cade13595b08 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -4680,7 +4680,6 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag,
>  			m->private = iter;
>  		} else {
>  			/* Failed */
> -			free_ftrace_hash(iter->hash);

The real fix is:

			if (file->f_mode & FMODE_WRITE)
				free_ftrace_hash(iter->hash);

-- Steve



>  			trace_parser_put(&iter->parser);
>  		}
>  	} else


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ