Skip to content

riscv: Assorted bug fixes

Michael Neuling linux-riscv lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5riscv: errata: Fix bitwise vs logical AND in MIPS errata patchingarch/riscv/errata/mips/errata.c+1 -11 reply
2/5riscv: ptrace: Fix register corruption in compat_riscv_gpr_set on errorarch/riscv/kernel/ptrace.c+2 -24 replies
3/5riscv: mm: Fix NULL pointer dereference in __set_memoryarch/riscv/mm/pageattr.c+4 -06 replies
4/5riscv: mm: Fix NULL dereferences in napot hugetlb functionsarch/riscv/mm/hugetlbpage.c+4 -01 reply
5/5riscv: mm: Fix TOCTOU race in remove_pte_mappingarch/riscv/mm/init.c+1 -11 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] riscv: Assorted bug fixes

This series contains five independent bug fixes across the RISC-V architecture code, found with the help of Claude AI (claude-4.6-opus):

1. riscv: errata: Fix bitwise vs logical AND in MIPS errata patching
- Logical AND (&&) was used instead of bitwise AND (&) when checking errata flags, causing all errata patches to be applied when any single one was detected.

2. riscv: ptrace: Fix register corruption in compat_riscv_gpr_set on error
- On copyin failure, uninitialized stack data was written into the target task's pt_regs, corrupting registers and potentially leaking kernel stack contents.

3. riscv: mm: Fix NULL pointer dereference in __set_memory
- find_vm_area() can return NULL but was dereferenced without a check.

4. riscv: mm: Fix NULL dereferences in napot hugetlb functions
- huge_pte_offset() can return NULL in the napot path but was used without NULL checks in huge_ptep_set_access_flags() and huge_ptep_set_wrprotect().

5. riscv: mm: Fix TOCTOU race in remove_pte_mapping
- The PTE was read twice (once via ptep_get, once via *ptep), creating a race window where another CPU could modify the PTE between reads.

All patches are small and self-contained. These bugs were identified through AI-assisted code review using Claude, which also assisted in writing the fixes. Each patch has been manually reviewed for correctness.

Michael Neuling (5):
riscv: errata: Fix bitwise vs logical AND in MIPS errata patching
riscv: ptrace: Fix register corruption in compat_riscv_gpr_set on
error
riscv: mm: Fix NULL pointer dereference in __set_memory
riscv: mm: Fix NULL dereferences in napot hugetlb functions
riscv: mm: Fix TOCTOU race in remove_pte_mapping

 arch/riscv/errata/mips/errata.c | 2 +-
 arch/riscv/kernel/ptrace.c      | 4 ++--
 arch/riscv/mm/hugetlbpage.c     | 4 ++++
 arch/riscv/mm/init.c            | 2 +-
 arch/riscv/mm/pageattr.c        | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0