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: <zllb6trx6rbheykxoj44bztbxzumseiedwwvyemv2y5vch2w6l@igkejk5b7qb3>
Date: Fri, 29 Aug 2025 11:41:28 -0400
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        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>,
        Kees Cook <kees@...nel.org>, David Hildenbrand <david@...hat.com>,
        Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
        Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
        Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
        Pasha Tatashin <pasha.tatashin@...een.com>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH 2/2] task_stack.h: Clean-up stack_not_used()
 implementation

* Linus Walleij <linus.walleij@...aro.org> [250829 07:44]:
> From: Pasha Tatashin <pasha.tatashin@...een.com>
> 
> Inside the small stack_not_used() function there are several ifdefs for
> stack growing-up vs. regular versions. Instead just implement this
> function two times, one for growing-up and another regular.
> 
> Add comments like /* !CONFIG_DEBUG_STACK_USAGE */ to clarify what the
> ifdefs are doing.
> 
> [linus.walleij@...aro.org: Rebased, function moved elsewhere in the kernel]
> Signed-off-by: Pasha Tatashin <pasha.tatashin@...een.com>
> Link: https://lore.kernel.org/20240311164638.2015063-13-pasha.tatashin@soleen.com
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>

Thanks for this.

Reviewed-by: Liam R. Howlett <Liam.Howlett@...cle.com>

> ---
>  kernel/exit.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 343eb97543d568baeb23142edcc9050a8b8be8bf..9f74e8f1c431b6aa6e391ff71aadf9895a3857ae 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -780,24 +780,29 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
>  }
>  
>  #ifdef CONFIG_DEBUG_STACK_USAGE
> +#ifdef CONFIG_STACK_GROWSUP
>  unsigned long stack_not_used(struct task_struct *p)
>  {
>  	unsigned long *n = end_of_stack(p);
>  
>  	do {	/* Skip over canary */
> -# ifdef CONFIG_STACK_GROWSUP
>  		n--;
> -# else
> -		n++;
> -# endif
>  	} while (!*n);
>  
> -# ifdef CONFIG_STACK_GROWSUP
>  	return (unsigned long)end_of_stack(p) - (unsigned long)n;
> -# else
> +}
> +#else /* !CONFIG_STACK_GROWSUP */
> +unsigned long stack_not_used(struct task_struct *p)
> +{
> +	unsigned long *n = end_of_stack(p);
> +
> +	do {	/* Skip over canary */
> +		n++;
> +	} while (!*n);
> +
>  	return (unsigned long)n - (unsigned long)end_of_stack(p);
> -# endif
>  }
> +#endif /* CONFIG_STACK_GROWSUP */
>  
>  /* Count the maximum pages reached in kernel stacks */
>  static inline void kstack_histogram(unsigned long used_stack)
> @@ -856,9 +861,9 @@ static void check_stack_usage(void)
>  	}
>  	spin_unlock(&low_water_lock);
>  }
> -#else
> +#else /* !CONFIG_DEBUG_STACK_USAGE */
>  static inline void check_stack_usage(void) {}
> -#endif
> +#endif /* CONFIG_DEBUG_STACK_USAGE */
>  
>  static void synchronize_group_exit(struct task_struct *tsk, long code)
>  {
> 
> -- 
> 2.50.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ