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: <9f37a8b5-7c88-427c-810e-56c0b1c7acf5@rivosinc.com>
Date: Mon, 4 Aug 2025 09:44:21 +0200
From: Clément Léger <cleger@...osinc.com>
To: Jesse Taube <jesse@...osinc.com>, linux-riscv@...ts.infradead.org,
 linux-kernel@...r.kernel.org
Cc: Paul Walmsley <paul.walmsley@...ive.com>,
 Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
 Alexandre Ghiti <alex@...ti.fr>, Oleg Nesterov <oleg@...hat.com>,
 Himanshu Chauhan <hchauhan@...tanamicro.com>,
 Charlie Jenkins <charlie@...osinc.com>,
 Samuel Holland <samuel.holland@...ive.com>, Deepak Gupta
 <debug@...osinc.com>, Andrew Jones <ajones@...tanamicro.com>,
 Atish Patra <atishp@...osinc.com>, Anup Patel <apatel@...tanamicro.com>,
 Mayuresh Chitale <mchitale@...tanamicro.com>,
 Conor Dooley <conor.dooley@...rochip.com>, WangYuli
 <wangyuli@...ontech.com>, Huacai Chen <chenhuacai@...nel.org>,
 Nam Cao <namcao@...utronix.de>, Andrew Morton <akpm@...ux-foundation.org>,
 "Mike Rapoport (Microsoft)" <rppt@...nel.org>,
 Luis Chamberlain <mcgrof@...nel.org>, Yunhui Cui <cuiyunhui@...edance.com>,
 Joel Granados <joel.granados@...nel.org>,
 Celeste Liu <coelacanthushex@...il.com>, Evan Green <evan@...osinc.com>,
 Nylon Chen <nylon.chen@...ive.com>
Subject: Re: [RFC PATCH 3/6] riscv: insn: __read_insn use copy_from_X_nofault



On 22/07/2025 19:38, Jesse Taube wrote:
> __read_insn was using get_user for user space reads and direct
> dereferencing for kernel space reads.
> Update to use copy_from_user_nofault, copy_from_kernel_nofault for this
> as get_user is user context only and may sleep.
> 
> Signed-off-by: Jesse Taube <jesse@...osinc.com>
> ---
> Squash with previous commit as it's breaks bisectability.
> Separated as i'm unsure if copy_from_user_nofault is an acceptable
> replacement.
> ---
>  arch/riscv/kernel/insn.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/kernel/insn.c b/arch/riscv/kernel/insn.c
> index dd2a6ef9fd25..b8e5202ddced 100644
> --- a/arch/riscv/kernel/insn.c
> +++ b/arch/riscv/kernel/insn.c
> @@ -2,6 +2,9 @@
>  /*
>   * Copyright 2025 Rivos, Inc
>   */
> +
> +#include <linux/uaccess.h>
> +
>  #include <asm/insn.h>
>  #include <asm/ptrace.h>
>  #include <asm/uaccess.h>
> @@ -11,10 +14,9 @@
>  	int __ret;					\
>  							\
>  	if (user_mode(regs)) {				\
> -		__ret = get_user(insn, (type __user *) insn_addr); \
> +		__ret = copy_from_user_nofault(&insn, (const type __user *) insn_addr, sizeof(type)); \
>  	} else {					\
> -		insn = *(type *)insn_addr;		\
> -		__ret = 0;				\
> +		__ret = copy_from_kernel_nofault(&insn, (const type *) insn_addr, sizeof(type)); \
>  	}						\

Hi Jesse,

This can not be used for misaligned accesses handling. As pointed out by
Samuel in a previous misaligned access handling patch, using the
no_fault() version would lead to access failure if the user memory is
swapped out. For that reason it was swapped from the no_fault() version
to the standard version.

Thanks,

Clément

>  							\
>  	__ret;						\


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ