* [PATCH] arm64/sve: Use correct size when reinitialising SVE state
@ 2021-09-09 16:53 Mark Brown
2021-09-16 17:08 ` Catalin Marinas
0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2021-09-09 16:53 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon; +Cc: linux-arm-kernel, Mark Brown, stable
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: bc0ee47603647 (arm64/sve: Core task context handling)
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
arch/arm64/kernel/fpsimd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 5a294f20e9de..ff4962750b3d 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -513,7 +513,7 @@ size_t sve_state_size(struct task_struct const *task)
void sve_alloc(struct task_struct *task)
{
if (task->thread.sve_state) {
- memset(task->thread.sve_state, 0, sve_state_size(current));
+ memset(task->thread.sve_state, 0, sve_state_size(task));
return;
}
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] arm64/sve: Use correct size when reinitialising SVE state
2021-09-09 16:53 [PATCH] arm64/sve: Use correct size when reinitialising SVE state Mark Brown
@ 2021-09-16 17:08 ` Catalin Marinas
0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2021-09-16 17:08 UTC (permalink / raw)
To: Mark Brown, Will Deacon; +Cc: stable, linux-arm-kernel
On Thu, 9 Sep 2021 17:53:56 +0100, Mark Brown wrote:
> 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.
>
> [...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64/sve: Use correct size when reinitialising SVE state
https://git.kernel.org/arm64/c/e35ac9d0b56e
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-16 17:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-09 16:53 [PATCH] arm64/sve: Use correct size when reinitialising SVE state Mark Brown
2021-09-16 17:08 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).