[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <mhng-709d96f9-92ec-4ea4-8db6-e983b6e34777@penguin>
Date: Tue, 02 Feb 2021 18:34:52 -0800 (PST)
From: Palmer Dabbelt <palmer@...belt.com>
To: alex@...ti.fr
CC: Paul Walmsley <paul.walmsley@...ive.com>, aou@...s.berkeley.edu,
dvyukov@...gle.com, linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org, alex@...ti.fr
Subject: Re: [PATCH] riscv: virt_addr_valid must check the address belongs to linear mapping
On Fri, 29 Jan 2021 09:31:05 PST (-0800), alex@...ti.fr wrote:
> virt_addr_valid macro checks that a virtual address is valid, ie that
> the address belongs to the linear mapping and that the corresponding
> physical page exists.
>
> Add the missing check that ensures the virtual address belongs to the
> linear mapping, otherwise __virt_to_phys, when compiled with
> CONFIG_DEBUG_VIRTUAL enabled, raises a WARN that is interpreted as a
> kernel bug by syzbot.
>
> Signed-off-by: Alexandre Ghiti <alex@...ti.fr>
> ---
> arch/riscv/include/asm/page.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> index 2d50f76efe48..64a675c5c30a 100644
> --- a/arch/riscv/include/asm/page.h
> +++ b/arch/riscv/include/asm/page.h
> @@ -135,7 +135,10 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);
>
> #endif /* __ASSEMBLY__ */
>
> -#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
> +#define virt_addr_valid(vaddr) ({ \
> + unsigned long _addr = (unsigned long)vaddr; \
> + (unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \
> +})
>
> #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
Thanks, this is on fixes.
Powered by blists - more mailing lists