[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250722173829.984082-4-jesse@rivosinc.com>
Date: Tue, 22 Jul 2025 10:38:26 -0700
From: Jesse Taube <jesse@...osinc.com>
To: 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>,
Jesse Taube <jesse@...osinc.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>,
Clément Léger <cleger@...osinc.com>,
Celeste Liu <coelacanthushex@...il.com>,
Evan Green <evan@...osinc.com>,
Nylon Chen <nylon.chen@...ive.com>
Subject: [RFC PATCH 3/6] riscv: insn: __read_insn use copy_from_X_nofault
__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)); \
} \
\
__ret; \
--
2.43.0
Powered by blists - more mailing lists