kernel-hacking-2024-linux-s.../arch
Andrew Cooper 9174adbee4 xen: Fix stack corruption in xen_failsafe_callback for 32bit PVOPS guests.
This fixes CVE-2013-0190 / XSA-40

There has been an error on the xen_failsafe_callback path for failed
iret, which causes the stack pointer to be wrong when entering the
iret_exc error path.  This can result in the kernel crashing.

In the classic kernel case, the relevant code looked a little like:

        popl %eax      # Error code from hypervisor
        jz 5f
        addl $16,%esp
        jmp iret_exc   # Hypervisor said iret fault
5:      addl $16,%esp
                       # Hypervisor said segment selector fault

Here, there are two identical addls on either option of a branch which
appears to have been optimised by hoisting it above the jz, and
converting it to an lea, which leaves the flags register unaffected.

In the PVOPS case, the code looks like:

        popl_cfi %eax         # Error from the hypervisor
        lea 16(%esp),%esp     # Add $16 before choosing fault path
        CFI_ADJUST_CFA_OFFSET -16
        jz 5f
        addl $16,%esp         # Incorrectly adjust %esp again
        jmp iret_exc

It is possible unprivileged userspace applications to cause this
behaviour, for example by loading an LDT code selector, then changing
the code selector to be not-present.  At this point, there is a race
condition where it is possible for the hypervisor to return back to
userspace from an interrupt, fault on its own iret, and inject a
failsafe_callback into the kernel.

This bug has been present since the introduction of Xen PVOPS support
in commit 5ead97c84 (xen: Core Xen implementation), in 2.6.23.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: stable@vger.kernel.org
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2013-01-16 16:17:42 -05:00
..
alpha Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-11-18 09:13:48 -10:00
arm Linux 3.7 2013-01-15 15:58:25 -05:00
arm64 open*(2) compat fixes (s390, arm64) 2012-12-02 10:46:38 -08:00
avr32
blackfin
c6x c6x: use generic kvm_para.h 2012-11-28 14:33:03 -05:00
cris
frv
h8300 h8300: add missing L1_CACHE_SHIFT 2012-11-09 06:41:47 +01:00
hexagon
ia64 revert "mm: fix-up zone present pages" 2012-11-16 14:33:04 -08:00
m32r
m68k m68k: fix sigset_t accessor functions 2012-11-18 10:32:16 +01:00
microblaze microblaze: rt_sigreturn is too trigger-happy about sigaltstack errors 2012-11-28 21:46:12 -05:00
mips MIPS: Fix endless loop when processing signals for kernel tasks 2012-12-05 19:59:00 +01:00
mn10300
openrisc openrisk: fix altstack switching on sigreturn 2012-11-28 21:46:11 -05:00
parisc [parisc] open(2) compat bug 2012-12-03 11:13:09 -08:00
powerpc powerpc/eeh: Do not invalidate PE properly 2012-11-26 09:14:16 +11:00
s390 open*(2) compat fixes (s390, arm64) 2012-12-02 10:46:38 -08:00
score score: do_sigaltstack() expects a userland pointer... 2012-11-28 21:46:12 -05:00
sh sh64: fix altstack switching on sigreturn 2012-11-28 21:46:11 -05:00
sparc sparc: Fix piggyback with newer binutils. 2012-12-03 11:24:25 -08:00
tile
um um: get_safe_registers() should be done in flush_thread(), not start_thread() 2012-11-28 21:46:03 -05:00
unicore32 arch/unicore32: remove CONFIG_EXPERIMENTAL 2012-11-09 17:30:10 +08:00
x86 xen: Fix stack corruption in xen_failsafe_callback for 32bit PVOPS guests. 2013-01-16 16:17:42 -05:00
xtensa
.gitignore
Kconfig