[PATCH v4] riscv: lib: Fix ZBB strnlen wrap-around regression on huge counts

patchwork-bot+linux-riscv at kernel.org patchwork-bot+linux-riscv at kernel.org
Mon Oct 5 10:00:13 PDT 2026


Hello:

This patch was applied to riscv/linux.git (fixes)
by Paul Walmsley <pjw at kernel.org>:

On Tue, 15 Sep 2026 15:26:56 +0800 (CST) you wrote:
> From: Shao Mingyin <shao.mingyin at zte.com.cn>
> 
> The aligned scan boundary is derived from the last valid byte,
> (s + count - 1).  When count is huge (e.g. SIZE_MAX, which FORTIFY
> strcat/strlcat pass when the destination size is not known at compile
> time), s + count wraps around and the boundary lands before s, so the
> ZBB path returns a bogus length.  The original implementation
> (5ba15d419fab) had the same wrap-around in its (s + count) & ~7
> boundary computation; after 5d588c684833 the wrapped boundary is caught
> by the pre-loop guard "bgeu t0, t4, 2f", which then always exits for
> aligned strings of 8 or more characters and strnlen() returns 8
> instead of the real length.
> 
> [...]

Here is the summary with links:
  - [v4] riscv: lib: Fix ZBB strnlen wrap-around regression on huge counts
    https://git.kernel.org/riscv/c/d3b055d5d168

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html





More information about the linux-riscv mailing list