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: <f686f36b-4c09-5099-3ba4-90f87f914654@rivosinc.com>
Date:   Tue, 13 Jun 2023 15:01:07 +0200
From:   Clément Léger <cleger@...osinc.com>
To:     guoren@...nel.org, arnd@...db.de, palmer@...osinc.com,
        conor.dooley@...rochip.com, heiko@...ech.de, jszhang@...nel.org,
        bjorn@...nel.org, greentime.hu@...ive.com, vincent.chen@...ive.com,
        andy.chiu@...ive.com, paul.walmsley@...ive.com
Cc:     linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-riscv@...ts.infradead.org, Guo Ren <guoren@...ux.alibaba.com>
Subject: Re: [PATCH -next V12 1/3] riscv: stack: Support
 HAVE_IRQ_EXIT_ON_IRQ_STACK



On 29/05/2023 10:45, guoren@...nel.org wrote:
> From: Guo Ren <guoren@...ux.alibaba.com>
> 
> Add independent irq stacks for percpu to prevent kernel stack overflows.
> It is also compatible with VMAP_STACK by arch_alloc_vmap_stack.
> 
> Tested-by: Jisheng Zhang <jszhang@...nel.org>
> Signed-off-by: Guo Ren <guoren@...ux.alibaba.com>
> Signed-off-by: Guo Ren <guoren@...nel.org>
> Cc: Conor Dooley <conor.dooley@...rochip.com>
> ---
>   arch/riscv/Kconfig                   |  7 ++++++
>   arch/riscv/include/asm/irq_stack.h   | 32 +++++++++++++++++++++++++
>   arch/riscv/include/asm/thread_info.h |  2 ++
>   arch/riscv/kernel/irq.c              | 33 ++++++++++++++++++++++++++
>   arch/riscv/kernel/traps.c            | 35 ++++++++++++++++++++++++++--
>   5 files changed, 107 insertions(+), 2 deletions(-)
>   create mode 100644 arch/riscv/include/asm/irq_stack.h
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index fa256f2e23c1..44b4c9690f94 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -588,6 +588,13 @@ config FPU
>   
>   	  If you don't know what to do here, say Y.
>   
> +config IRQ_STACKS
> +	bool "Independent irq stacks" if EXPERT
> +	default y
> +	select HAVE_IRQ_EXIT_ON_IRQ_STACK
> +	help
> +	  Add independent irq stacks for percpu to prevent kernel stack overflows.
> +
>   endmenu # "Platform type"
>   
>   menu "Kernel features"
> diff --git a/arch/riscv/include/asm/irq_stack.h b/arch/riscv/include/asm/irq_stack.h
> new file mode 100644
> index 000000000000..b0dcee9a3fa2
> --- /dev/null
> +++ b/arch/riscv/include/asm/irq_stack.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _ASM_RISCV_IRQ_STACK_H
> +#define _ASM_RISCV_IRQ_STACK_H
> +
> +#include <linux/bug.h>
> +#include <linux/gfp.h>
> +#include <linux/kconfig.h>
> +#include <linux/vmalloc.h>
> +#include <linux/pgtable.h>
> +#include <asm/thread_info.h>
> +
> +DECLARE_PER_CPU(ulong *, irq_stack_ptr);
> +
> +#ifdef CONFIG_VMAP_STACK
> +/*
> + * To ensure that VMAP'd stack overflow detection works correctly, all VMAP'd
> + * stacks need to have the same alignment.
> + */
> +static inline unsigned long *arch_alloc_vmap_stack(size_t stack_size, int node)
> +{
> +	void *p;
> +
> +	BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));

Hi Guo,

Since this function is already guarded with #ifdef CONFIG_VMAP_STACK, I 
guess this BUILD_BUG_ON() is unnecessary).

Clément

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ