]> xenbits.xensource.com Git - xen.git/commit
x86/pv: Avoid double exception injection
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 22 Sep 2020 13:49:19 +0000 (15:49 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 13:49:19 +0000 (15:49 +0200)
commit910093d54fc758e7d69261b344fdc8da3a7bd81e
tree1aa3ca94e4f467ab22861c19493548cb260c533f
parente59ce972d1280c6c55065da822e0860845582053
x86/pv: Avoid double exception injection

There is at least one path (SYSENTER with NT set, Xen converts to #GP) which
ends up injecting the #GP fault twice, first in compat_sysenter(), and then a
second time in compat_test_all_events(), due to the stale TBF_EXCEPTION left
in TRAPBOUNCE_flags.

The guest kernel sees the second fault first, which is a kernel level #GP
pointing at the head of the #GP handler, and is therefore a userspace
trigger-able DoS.

This particular bug has bitten us several times before, so rearrange
{compat_,}create_bounce_frame() to clobber TRAPBOUNCE on success, rather than
leaving this task to one area of code which isn't used uniformly.

Other scenarios which might result in a double injection (e.g. two calls
directly to compat_create_bounce_frame) will now crash the guest, which is far
more obvious than letting the kernel run with corrupt state.

This is XSA-339

Fixes: fdac9515607b ("x86: clear EFLAGS.NT in SYSENTER entry path")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/x86_64/compat/entry.S
xen/arch/x86/x86_64/entry.S