Skip to content

Commit fa2016a

Browse files
amlutoingomolnar
authored andcommitted
x86/xen/64: Fix the reported SS and CS in SYSCALL
When I cleaned up the Xen SYSCALL entries, I inadvertently changed the reported segment registers. Before my patch, regs->ss was __USER(32)_DS and regs->cs was __USER(32)_CS. After the patch, they are FLAT_USER_CS/DS(32). This had a couple unfortunate effects. It confused the opportunistic fast return logic. It also significantly increased the risk of triggering a nasty glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21269 Update the Xen entry code to change it back. Reported-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andrew Cooper <andrew.cooper3@citrix.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Juergen Gross <jgross@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: xen-devel@lists.xenproject.org Fixes: 8a9949b ("x86/xen/64: Rearrange the SYSCALL entries") Link: http://lkml.kernel.org/r/daba8351ea2764bb30272296ab9ce08a81bd8264.1502775273.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent bf4d1a8 commit fa2016a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎arch/x86/xen/xen-asm_64.S‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ RELOC(xen_sysret64, 1b+1)
8888
ENTRY(xen_syscall_target)
8989
popq %rcx
9090
popq %r11
91+
92+
/*
93+
* Neither Xen nor the kernel really knows what the old SS and
94+
* CS were. The kernel expects __USER_DS and __USER_CS, so
95+
* report those values even though Xen will guess its own values.
96+
*/
97+
movq $__USER_DS, 4*8(%rsp)
98+
movq $__USER_CS, 1*8(%rsp)
99+
91100
jmp entry_SYSCALL_64_after_hwframe
92101
ENDPROC(xen_syscall_target)
93102

@@ -97,6 +106,15 @@ ENDPROC(xen_syscall_target)
97106
ENTRY(xen_syscall32_target)
98107
popq %rcx
99108
popq %r11
109+
110+
/*
111+
* Neither Xen nor the kernel really knows what the old SS and
112+
* CS were. The kernel expects __USER32_DS and __USER32_CS, so
113+
* report those values even though Xen will guess its own values.
114+
*/
115+
movq $__USER32_DS, 4*8(%rsp)
116+
movq $__USER32_CS, 1*8(%rsp)
117+
100118
jmp entry_SYSCALL_compat_after_hwframe
101119
ENDPROC(xen_syscall32_target)
102120

0 commit comments

Comments
 (0)