]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
arm64/sve: Use correct size when reinitialising SVE state
authorMark Brown <broonie@kernel.org>
Thu, 9 Sep 2021 16:53:56 +0000 (17:53 +0100)
committerKelsey Skunberg <kelsey.skunberg@canonical.com>
Tue, 12 Oct 2021 22:31:41 +0000 (16:31 -0600)
commit0fd81783bb806f429624f5b9c3301ef1b5e0e998
treec7c0581f1215dada956a4e16422a887cced188f6
parent3649b425710b76c386cd11134b9c927d77e57691
arm64/sve: Use correct size when reinitialising SVE state

BugLink: https://bugs.launchpad.net/bugs/1946802
commit e35ac9d0b56e9efefaeeb84b635ea26c2839ea86 upstream.

When we need a buffer for SVE register state we call sve_alloc() to make
sure that one is there. In order to avoid repeated allocations and frees
we keep the buffer around unless we change vector length and just memset()
it to ensure a clean register state. The function that deals with this
takes the task to operate on as an argument, however in the case where we
do a memset() we initialise using the SVE state size for the current task
rather than the task passed as an argument.

This is only an issue in the case where we are setting the register state
for a task via ptrace and the task being configured has a different vector
length to the task tracing it. In the case where the buffer is larger in
the traced process we will leak old state from the traced process to
itself, in the case where the buffer is smaller in the traced process we
will overflow the buffer and corrupt memory.

Fixes: bc0ee4760364 ("arm64/sve: Core task context handling")
Cc: <stable@vger.kernel.org> # 4.15.x
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210909165356.10675-1-broonie@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
arch/arm64/kernel/fpsimd.c