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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8fb18e4166be8ef59ed0ccb7fa2f79844220aec2.camel@xry111.site>
Date: Sun, 29 Sep 2024 16:19:03 +0800
From: Xi Ruoyao <xry111@...111.site>
To: Huacai Chen <chenhuacai@...ngson.cn>, Arnd Bergmann <arnd@...db.de>, 
 Huacai Chen <chenhuacai@...nel.org>
Cc: loongarch@...ts.linux.dev, linux-arch@...r.kernel.org, Xuefeng Li
	 <lixuefeng@...ngson.cn>, Guo Ren <guoren@...nel.org>, Xuerui Wang
	 <kernel@...0n.name>, Jiaxun Yang <jiaxun.yang@...goat.com>, 
	linux-kernel@...r.kernel.org, loongson-kernel@...ts.loongnix.cn
Subject: Re: [PATCH] LoongArch: Set correct size for VDSO code mapping

On Sun, 2024-09-29 at 15:49 +0800, Huacai Chen wrote:
> The current size of VDSO code mapping is hardcoded to PAGE_SIZE. This
> cannot work for 4KB page size after commit 18efd0b10e0fd77 ("LoongArch:
> vDSO: Wire up getrandom() vDSO implementation") because the code size
> increases to 8KB. Thus set the code mapping size to its real size, i.e.
> PAGE_ALIGN(vdso_end - vdso_start).

I get:

$ size vdso.so
   text	   data	    bss	    dec	   
hex	filename
   3716	    328	      0	   4044	   
fcc	vdso.so

So it "just" fits in 4 KiB, and of course it may exceed 4 KiB with a
different compiler or some kernel configuration affecting code
generation like CONFIG_INIT_STACK_ALL_ZERO or
CONFIG_ZERO_CALL_USED_REGS).

I remember I've checked `size vdso.so` before but I cannot remember why
I didn't realize a problem here.  Sorry for the stupidity.

Reviewed-by: Xi Ruoyao <xry111@...111.site>

> 
> Fixes: 18efd0b10e0fd77 ("LoongArch: vDSO: Wire up getrandom() vDSO implementation")
> Signed-off-by: Huacai Chen <chenhuacai@...ngson.cn>
> ---
>  arch/loongarch/kernel/vdso.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
> index f6fcc52aefae..7e0cc7f5e1ed 100644
> --- a/arch/loongarch/kernel/vdso.c
> +++ b/arch/loongarch/kernel/vdso.c
> @@ -85,7 +85,6 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
>  
>  struct loongarch_vdso_info vdso_info = {
>  	.vdso = vdso_start,
> -	.size = PAGE_SIZE,
>  	.code_mapping = {
>  		.name = "[vdso]",
>  		.pages = vdso_pages,
> @@ -103,7 +102,7 @@ static int __init init_vdso(void)
>  	unsigned long i, cpu, pfn;
>  
>  	BUG_ON(!PAGE_ALIGNED(vdso_info.vdso));
> -	BUG_ON(!PAGE_ALIGNED(vdso_info.size));
> +	vdso_info.size = PAGE_ALIGN(vdso_end - vdso_start);
>  
>  	for_each_possible_cpu(cpu)
>  		vdso_pdata[cpu].node = cpu_to_node(cpu);

-- 
Xi Ruoyao <xry111@...111.site>
School of Aerospace Science and Technology, Xidian University

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ