arm64/fpsimd: ptrace: Fix inactive SVE and SSVE regsets
authorKarl Mehltretter <kmehltretter@gmail.com>
Wed, 29 Jul 2026 00:42:54 +0000 (02:42 +0200)
committerWill Deacon <will@kernel.org>
Sun, 2 Aug 2026 09:46:07 +0000 (09:46 +0000)
commitc3f83d021162571bcd87b062ec9e587828d2b7f3
tree4ab335ab7eb5f4a15b0c278323df60e24b74883f
parenta13c140cc289c0b7b3770bce5b3ad42ab35074aa
arm64/fpsimd: ptrace: Fix inactive SVE and SSVE regsets

sve_init_header_from_task() takes header as a pointer, so for the
inactive mode

header->size = sizeof(header);

stores 8 rather than sizeof(struct user_sve_header), which is 16.
Userspace sees an impossible size smaller than the header it
describes.

The inactive-mode check in sve_get_common() compares header.size
against sizeof(header) as well, but there header is a struct, so the
check can never fire. Reads of NT_ARM_SVE and NT_ARM_SSVE for the
inactive mode therefore still return the other mode's FPSIMD data,
exactly the situation the check was added to prevent.

Fix the size, and make the check return the remaining membuf space
instead of 0, which regset_get() would interpret as the entire
(zero-filled) buffer having been populated.

Fixes: b93e685ecff7 ("arm64/fpsimd: ptrace: Do not present register data for inactive mode")
Assisted-by: Claude:claude-opus-5
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/ptrace.c