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: <6909622a-7d96-41ff-aee1-d3b216033cfe@roeck-us.net>
Date: Tue, 6 Jan 2026 17:47:22 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v2] ftrace: Do not over-allocate ftrace memory

On Tue, Jan 06, 2026 at 07:52:41PM -0500, Steven Rostedt wrote:
> On Tue,  6 Jan 2026 16:24:28 -0800
> Guenter Roeck <linux@...ck-us.net> wrote:
> 
> >  	if (pg_unuse) {
> > -		unsigned long pg_remaining, remaining = 0;
> > -		unsigned long skip;
> > -
> > -		/* Count the number of entries unused and compare it to skipped. */
> > -		pg_remaining = (ENTRIES_PER_PAGE << pg->order) - pg->index;
> > -
> 
> The above needs to be fixed though.

Yes, and
	skip = DIV_ROUND_UP(skip, ENTRIES_PER_PAGE);

is also wrong. That means

	WARN(skip != remaining, "Extra allocated pages for ftrace: %lu with %lu skipped",
	     remaining, skipped);

will be hit because because 'skip' may be inaccurate. Example with added
debug log:

ftrace: skipped: 654 pg_remaining: 313 skip: 341 (3) pages: 310 remaining: 2
------------[ cut here ]------------
Extra allocated pages for ftrace: 2 with 654 skipped
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:7299 ftrace_process_locs+0x5a8/0x5c0
...
ftrace: allocating 52250 entries in 308 pages
ftrace: allocated 308 pages with 4 groups

The warning is seen because the number of pages needed for 341 entries is
mis-calculated as 3 instead of 2.

That means I'll need the added code from v1 to calculate the correct value
for the number of pages needed, at least if you want to keep the validation
code with the warning backtraces.

Thanks,
Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ