Merge tag 'riscv-for-linus-v7.2-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Paul Walmsley:

 - Fix a fault caused when the RISC-V Zbb-enabled strlen() is executed
   on a string that ends right before a page boundary, when the next
   page is unmapped

 - Fix a race with the misaligned vector performance testing code that
   can prevent the outcome of the test from being stored into the vDSO
   cache

 - Fix a kernel warning generated by the ftrace code when
   ftrace_modify_call_code() runs against a ftrace-traced function where
   a kprobe has already been attached. This shows up in the bpf
   kselftests

* tag 'riscv-for-linus-v7.2-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: lib: Fix ZBB strnlen reading past count boundary
  riscv: hwprobe: Register unaligned probes before usermode
  riscv: ftrace: Fix ftrace_modify_call failure on kprobed functions
This commit is contained in:
Linus Torvalds
2026-08-14 07:51:55 -07:00
3 changed files with 20 additions and 3 deletions

View File

@@ -12,6 +12,7 @@
#include <linux/stop_machine.h>
#include <asm/cacheflush.h>
#include <asm/text-patching.h>
#include <asm/insn.h>
#ifdef CONFIG_DYNAMIC_FTRACE
void ftrace_arch_code_modify_prepare(void)
@@ -63,7 +64,9 @@ static int __ftrace_modify_call(unsigned long source, unsigned long target, bool
if (copy_from_kernel_nofault(replaced, (void *)source, 2 * MCOUNT_INSN_SIZE))
return -EFAULT;
if (replaced[0] != call[0]) {
/* Bypass the check if the auipc insn is a kprobe breakpoint */
if (replaced[0] != call[0] &&
!(riscv_insn_is_ebreak(replaced[0]) || riscv_insn_is_c_ebreak(replaced[0]))) {
pr_err("%p: expected (%08x) but got (%08x)\n",
(void *)source, call[0], replaced[0]);
return -EINVAL;

View File

@@ -411,4 +411,10 @@ static int __init check_unaligned_access_all_cpus(void)
return 0;
}
late_initcall(check_unaligned_access_all_cpus);
/*
* Run after clocksource_done_booting() so measure_cycles() uses a stable
* clocksource, but before rootfs_initcall() enables usermode helpers. Those
* helpers can reach hwprobe and populate the vDSO cache, so async hwprobe
* probes must be registered first.
*/
fs_initcall_sync(check_unaligned_access_all_cpus);

View File

@@ -83,8 +83,13 @@ strnlen_zbb:
sub t3, t3, t2
slli t2, t2, 3
/* Aligned boundary. */
/*
* Aligned boundary. Use the address of the last valid byte
* (s + count - 1) to avoid loading a word past the count
* boundary in the loop below. count == 0 is handled above.
*/
add t4, a0, a1
addi t4, t4, -1
andi t4, t4, -SZREG
/* Get the first word. */
@@ -120,6 +125,9 @@ strnlen_zbb:
bgtu t3, a0, 2f
/* All remaining bytes are in the first word, no loop needed. */
bgeu t0, t4, 2f
/* Prepare for the word comparison loop. */
addi t2, t0, SZREG
li t3, -1