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: <202507230031.52B5C2B53@keescook>
Date: Wed, 23 Jul 2025 00:31:28 -0700
From: Kees Cook <kees@...nel.org>
To: Xuanye Liu <liuqiye2025@....com>
Cc: Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
	Juri Lelli <juri.lelli@...hat.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	David Hildenbrand <david@...hat.com>,
	Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
	"Liam R. Howlett" <Liam.Howlett@...cle.com>,
	Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
	Suren Baghdasaryan <surenb@...gle.com>,
	Michal Hocko <mhocko@...e.com>,
	Dietmar Eggemann <dietmar.eggemann@....com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
	Valentin Schneider <vschneid@...hat.com>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: add stack trace when bad rss-counter state is
 detected

On Wed, Jul 23, 2025 at 03:23:49PM +0800, Xuanye Liu wrote:
> The check_mm() function verifies the correctness of rss counters in
> struct mm_struct. Currently, it only prints an alert when a bad
> rss-counter state is detected, but lacks sufficient context for
> debugging.
> 
> This patch adds a dump_stack() call to provide a stack trace when
> the rss-counter state is invalid. This helps developers identify
> where the corrupted mm_struct is being checked and trace the
> underlying cause of the inconsistency.

Why not just convert the pr_alert to a WARN?

-Kees

> 
> Signed-off-by: Xuanye Liu <liuqiye2025@....com>
> ---
>  kernel/fork.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index cfe2f1df5f27..d38f1c5270ea 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -584,9 +584,11 @@ static void check_mm(struct mm_struct *mm)
>  	for (i = 0; i < NR_MM_COUNTERS; i++) {
>  		long x = percpu_counter_sum(&mm->rss_stat[i]);
>  
> -		if (unlikely(x))
> +		if (unlikely(x)) {
>  			pr_alert("BUG: Bad rss-counter state mm:%p type:%s val:%ld\n",
>  				 mm, resident_page_types[i], x);
> +			dump_stack();
> +		}
>  	}
>  
>  	if (mm_pgtables_bytes(mm))
> -- 
> 2.43.0
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ