]> git.baikalelectronics.ru Git - kernel.git/commit
x86/ptrace: Fix xfpregs_set()'s incorrect xmm clearing
authorAndy Lutomirski <luto@kernel.org>
Mon, 14 Feb 2022 12:05:49 +0000 (13:05 +0100)
committerBorislav Petkov <bp@suse.de>
Fri, 18 Feb 2022 10:23:21 +0000 (11:23 +0100)
commitca169d434332758f678aa198ea58e59b5918069a
treed2a0c3287e9e54c622e3f79c74ce7ea900005483
parent291e7bfc97ed2d5cfca7577ddce845b70c26d212
x86/ptrace: Fix xfpregs_set()'s incorrect xmm clearing

xfpregs_set() handles 32-bit REGSET_XFP and 64-bit REGSET_FP. The actual
code treats these regsets as modern FX state (i.e. the beginning part of
XSTATE). The declarations of the regsets thought they were the legacy
i387 format. The code thought they were the 32-bit (no xmm8..15) variant
of XSTATE and, for good measure, made the high bits disappear by zeroing
the wrong part of the buffer. The latter broke ptrace, and everything
else confused anyone trying to understand the code. In particular, the
nonsense definitions of the regsets confused me when I wrote this code.

Clean this all up. Change the declarations to match reality (which
shouldn't change the generated code, let alone the ABI) and fix
xfpregs_set() to clear the correct bits and to only do so for 32-bit
callers.

Fixes: a5996b872793 ("x86/fpu: Rewrite xfpregs_set()")
Reported-by: Luís Ferreira <contact@lsferreira.net>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=215524
Link: https://lore.kernel.org/r/YgpFnZpF01WwR8wU@zn.tnic
arch/x86/kernel/fpu/regset.c
arch/x86/kernel/ptrace.c