KernelScan.io

CRITICAL Introduced in 7.1

riscv Strnlen OOB

CVE-2026-74751

CVSS 9.4 / 10.0 NVD

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:H

KernelScan AI6.2MEDIUM

01

In the Linux kernel, the following vulnerability has been resolved: riscv: lib: Fix ZBB strnlen reading past count boundary The ZBB-optimized strnlen loop loads one word ahead before checking the aligned boundary: REG_L t1, SZREG(t0) // load next word addi t0, t0, SZREG // advance orc.b t1, t1 bgeu t0, t4, 4f // boundary check AFTER load where t4 = (s + count) & -SZREG. When s is aligned and count is a multiple of SZREG, t4 equals s + count and the loop loads a full word starting at exactly s + count. If s + count falls on a page boundary with the next page unmapped, this faults. Fix by computing the aligned boundary from the last valid byte (s + count - 1) instead of s + count. This makes the loop stop at the word containing the last valid byte rather than potentially loading the word after it. The count == 0 case is already handled by the beqz early exit. Also add a pre-loop guard (bgeu t0, t4) for the case where all valid bytes fit within the first word. With the adjusted boundary, t4 can equal t0, and entering the loop with stale register state from the first-word processing would produce incorrect results. The final minu clamp ensures the result is still correct when the last loaded word extends past s + count - 1 within the same aligned word.

02

Engine v0.6.0

Risk summary

A local unprivileged user on a RISC-V system with the ZBB extension can trigger a kernel panic by invoking syscalls whose internal code paths call strnlen on a buffer positioned near a page boundary. The over-read does not leak or corrupt data but crashes the kernel, causing a denial of service. No special privileges or hardware beyond a RISC-V CPU with ZBB are required.

Affectedarch/riscv/lib/strnlen.S (RISC-V lib)

Vulnerability analysis

The ZBB-optimized strnlen routine on RISC-V loads one machine word past the specified length boundary before checking whether the end of the valid region has been reached. When the byte immediately after the valid region falls on a page boundary and the following page is unmapped, this speculative load triggers a kernel page fault that crashes the system. The fix changes the loop's boundary calculation to use the address of the last valid byte rather than the first byte past the end, so the loop never loads a word beyond the valid region; a pre-loop guard is also added to handle the case where all valid bytes fit in a single word. Any local user can trigger this through ordinary system calls that internally call strnlen on kernel buffers; no special privileges are required, but the system must be RISC-V with the ZBB extension enabled.

03

BranchIntroducedFixed inPatch commit
mainline7.17.25d588c684833
7.17.17.1.10e697e30f3dd2