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: <20250727155047.GA1183915@ax162>
Date: Sun, 27 Jul 2025 08:50:47 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Kees Cook <kees@...nel.org>
Cc: Youling Tang <tangyouling@...inos.cn>,
	Huacai Chen <chenhuacai@...ngson.cn>,
	Huacai Chen <chenhuacai@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Pasha Tatashin <pasha.tatashin@...een.com>,
	"Peter Zijlstra (Intel)" <peterz@...radead.org>,
	David Disseldorp <ddiss@...e.de>,
	Qun-Wei Lin <qun-wei.lin@...iatek.com>,
	linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] sched/task_stack: Add missing const qualifier to
 end_of_stack()

On Sat, Jul 26, 2025 at 02:06:46PM -0700, Kees Cook wrote:
> Add missing const qualifier to the non-CONFIG_THREAD_INFO_IN_TASK
> version of end_of_stack() to match the CONFIG_THREAD_INFO_IN_TASK
> version. Fixes a warning with CONFIG_KSTACK_ERASE=y on archs that don't
> select THREAD_INFO_IN_TASK (such as LoongArch):
> 
>   error: passing 'const struct task_struct *' to parameter of type 'struct task_struct *' discards qualifiers
> 
> The stackleak_task_low_bound() function correctly uses a const task
> parameter, but the legacy end_of_stack() prototype didn't like that.
> 
> Build tested on loongarch (with CONFIG_KSTACK_ERASE=y) and m68k
> (with CONFIG_DEBUG_STACK_USAGE=y).
> 
> Fixes: a45728fd4120 ("LoongArch: Enable HAVE_ARCH_STACKLEAK")
> Reported-by: Nathan Chancellor <nathan@...nel.org>
> Closes: https://lore.kernel.org/all/20250726004313.GA3650901@ax162
> Cc: Youling Tang <tangyouling@...inos.cn>
> Cc: Huacai Chen <chenhuacai@...ngson.cn>
> Signed-off-by: Kees Cook <kees@...nel.org>

Tested-by: Nathan Chancellor <nathan@...nel.org>

> ---
>  include/linux/sched/task_stack.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h
> index 85c5a6392e02..1fab7e9043a3 100644
> --- a/include/linux/sched/task_stack.h
> +++ b/include/linux/sched/task_stack.h
> @@ -53,7 +53,7 @@ static inline void setup_thread_stack(struct task_struct *p, struct task_struct
>   * When the stack grows up, this is the highest address.
>   * Beyond that position, we corrupt data on the next page.
>   */
> -static inline unsigned long *end_of_stack(struct task_struct *p)
> +static inline unsigned long *end_of_stack(const struct task_struct *p)
>  {
>  #ifdef CONFIG_STACK_GROWSUP
>  	return (unsigned long *)((unsigned long)task_thread_info(p) + THREAD_SIZE) - 1;
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ