Skip to contentSkip to conversation

x86/fpu: XRSTOR is expected to raise #GP

PATCH Superseded Jann Horn 4 participants 5 messages Nov 26, 2018 – Nov 28, 2018 x86

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jann Horn

author
#0 lore raw

PATCH 1/1 x86/fpu: XRSTOR is expected to raise #GP

commit 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups") incorrectly replaced the fixup entry for XSTATE_OP with a user-#PF-only fixup. However, XRSTOR can also raise #GP when the supplied address points to userspace memory. Change it back.

Fixes 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups")
---
 arch/x86/include/asm/fpu/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/fpu/internal.h +1 -1
index 5f7290e6e954..69dcdf195b61 100644
@@ -226,7 +226,7 @@ static inline void copy_fxregs_to_kernel(struct fpu *fpu)
 		     "3: movl $-2,%[err]\n\t"				\
 		     "jmp 2b\n\t"					\
 		     ".popsection\n\t"					\
-		     _ASM_EXTABLE_UA(1b, 3b)				\
+		     _ASM_EXTABLE(1b, 3b)				\
 		     : [err] "=r" (err)					\
 		     : "D" (st), "m" (*st), "a" (lmask), "d" (hmask)	\
 		     : "memory")
Signature · 1 line
2.20.0.rc0.387.gc7a69e6b6c-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jann Horn

commit 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups") incorrectly replaced the fixup entry for XSTATE_OP with a user-#PF-only fixup. However, XRSTOR can also raise #GP when the supplied address points to userspace memory. Change it back.

The #GP is raised if the xstate content is invalid. But I guess the details don't matter.

Quoted 3 lines
Fixes 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups")
Quoted 9 lines
---
 arch/x86/include/asm/fpu/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/fpu/internal.h +0 -0
index 5f7290e6e954..69dcdf195b61 100644

arch/x86/include/asm/fpu/internal.h static inline void copy_fxregs_to_kernel(struct fpu *fpu) · line 229

Quoted 5 lines
arch/x86/include/asm/fpu/internal.h +1 -1
@@ -226,7 +226,7 @@ static inline void copy_fxregs_to_kernel(struct fpu *fpu)
 		     "3: movl $-2,%[err]\n\t"				\
 		     "jmp 2b\n\t"					\
 		     ".popsection\n\t"					\
-		     _ASM_EXTABLE_UA(1b, 3b)				\
+		     _ASM_EXTABLE(1b, 3b)				\

So you revert to what we had before. That works, tested.

Quoted 5 lines
arch/x86/include/asm/fpu/internal.h +0 -0
 		     : [err] "=r" (err)					\
 		     : "D" (st), "m" (*st), "a" (lmask), "d" (hmask)	\
 		     : "memory")
Signature · 1 line
2.20.0.rc0.387.gc7a69e6b6c-goog

Sebastian

#2 lore raw
Quoted 6 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Jann Horn

commit 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups") incorrectly replaced the fixup entry for XSTATE_OP with a user-#PF-only fixup. However, XRSTOR can also raise #GP when the supplied address points to userspace memory. Change it back.

Quoted 8 lines

The #GP is raised if the xstate content is invalid. But I guess the details don't matter.

Quoted 3 lines
Fixes 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups")

It does matter -- please correct the patch description, or we might have some serious confusion at some arbitrary point in the future with the result that the bug gets re-introduced; it would not be the first time.

-hpa

#3 lore raw

From: H. Peter Anvin

Quoted 14 lines

Sent: 26 November 2018 19:50

Quoted 12 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Jann Horn

commit 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups") incorrectly replaced the fixup entry for XSTATE_OP with a user-#PF-only fixup. However, XRSTOR can also raise #GP when the supplied address points to userspace memory. Change it back.

The #GP is raised if the xstate content is invalid. But I guess the details don't matter.

Quoted 3 lines
Fixes 75045f77f7a7 ("x86/extable: Introduce _ASM_EXTABLE_UA for uaccess fixups")
Quoted 6 lines
Quoted 2 lines

It does matter -- please correct the patch description, or we might have some serious confusion at some arbitrary point in the future with the result that the bug gets re-introduced; it would not be the first time.

Better still note it in the code.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#4 lore raw
Quoted 1 line · David Laight

Better still note it in the code.

I'm in favour of adding something to tools/testing/selftests/x86/.

Quoted 1 line

David

Sebastian