]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
riscv: ptrace: validate input vector csr registers
authorSergey Matyukevich <geomatsi@gmail.com>
Mon, 26 Jan 2026 04:09:57 +0000 (21:09 -0700)
committerPaul Walmsley <pjw@kernel.org>
Mon, 9 Feb 2026 22:27:33 +0000 (15:27 -0700)
commitf4be988f5b547dc4b305c15a078a52cdde76a8f5
treed7795ab2e9400cef8fb6a25c77c98df6f351d612
parentfd515e037efb3b6300eace247e14ab2bc7e38db5
riscv: ptrace: validate input vector csr registers

Add strict validation for vector csr registers when setting them via
ptrace:
- reject attempts to set reserved bits or invalid field combinations
- enforce strict VL checks against calculated VLMAX values

Vector specs 0.7.1 and 1.0 allow normal applications to set candidate
VL values and read back the hardware-adjusted results, see section 6
for details. Disallow such flexibility in vector ptrace operations
and strictly enforce valid VL input.

The traced process may not update its saved vector context if no vector
instructions execute between breakpoints. So the purpose of the strict
ptrace approach is to make sure that debuggers maintain an accurate view
of the tracee's vector context across multiple halt/resume debug cycles.

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
Reviewed-by: Andy Chiu <andybnac@gmail.com>
Tested-by: Andy Chiu <andybnac@gmail.com>
Link: https://patch.msgid.link/20251214163537.1054292-5-geomatsi@gmail.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/ptrace.c