[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhV-H6hTFrUO5gTx6FYo89TAouEykTvKpLNkqFfhtsg0PVLiw@mail.gmail.com>
Date: Thu, 18 Sep 2025 15:06:51 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: lgs201920130244@...il.com
Cc: WANG Xuerui <kernel@...0n.name>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
Thomas Gleixner <tglx@...utronix.de>, Nam Cao <namcao@...nel.org>, Xi Ruoyao <xry111@...111.site>,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org,
Guangshuo Li <202321181@...l.sdu.edu.cn>, stable@...r.kernel.org
Subject: Re: [PATCH] LoongArch: vDSO: check kcalloc() result in init_vdso
Applied, thanks.
Huacai
On Tue, Sep 16, 2025 at 10:57 PM <lgs201920130244@...il.com> wrote:
>
> From: Guangshuo Li <202321181@...l.sdu.edu.cn>
>
> Add a NULL-pointer check after the kcalloc() call in init_vdso(). If
> allocation fails, return -ENOMEM to prevent a possible dereference of
> vdso_info.code_mapping.pages when it is NULL.
>
> Fixes: 2ed119aef60d ("LoongArch: Set correct size for vDSO code mapping")
> Cc: stable@...r.kernel.org
> Signed-off-by: Guangshuo Li <202321181@...l.sdu.edu.cn>
> ---
> arch/loongarch/kernel/vdso.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
> index 10cf1608c7b3..da7a7922fb24 100644
> --- a/arch/loongarch/kernel/vdso.c
> +++ b/arch/loongarch/kernel/vdso.c
> @@ -53,7 +53,8 @@ static int __init init_vdso(void)
> vdso_info.size = PAGE_ALIGN(vdso_end - vdso_start);
> vdso_info.code_mapping.pages =
> kcalloc(vdso_info.size / PAGE_SIZE, sizeof(struct page *), GFP_KERNEL);
> -
> + if (!vdso_info.code_mapping.pages)
> + return -ENOMEM;
> pfn = __phys_to_pfn(__pa_symbol(vdso_info.vdso));
> for (i = 0; i < vdso_info.size / PAGE_SIZE; i++)
> vdso_info.code_mapping.pages[i] = pfn_to_page(pfn + i);
> --
> 2.43.0
>
Powered by blists - more mailing lists