qemu-e2k/target/i386
Paolo Bonzini b066c53757 target/i386: trap on instructions longer than >15 bytes
Besides being more correct, arbitrarily long instruction allow the
generation of a translation block that spans three pages.  This
confuses the generator and even allows ring 3 code to poison the
translation block cache and inject code into other processes that are
in guest ring 3.

This is an improved (and more invasive) fix for commit 30663fd ("tcg/i386:
Check the size of instruction being translated", 2017-03-24).  In addition
to being more precise (and generating the right exception, which is #GP
rather than #UD), it distinguishes better between page faults and too long
instructions, as shown by this test case:

    #include <sys/mman.h>
    #include <string.h>
    #include <stdio.h>

    int main()
    {
            char *x = mmap(NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC,
                           MAP_PRIVATE|MAP_ANON, -1, 0);
            memset(x, 0x66, 4096);
            x[4096] = 0x90;
            x[4097] = 0xc3;
            char *i = x + 4096 - 15;
            mprotect(x + 4096, 4096, PROT_READ|PROT_WRITE);
            ((void(*)(void)) i) ();
    }

... which produces a #GP without the mprotect, and a #PF with it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-10-16 18:03:53 +02:00
..
arch_dump.c exec,dump,i386,ppc,s390x: don't include exec/cpu-all.h explicitly 2017-09-19 18:21:33 +02:00
arch_memory_mapping.c exec,dump,i386,ppc,s390x: don't include exec/cpu-all.h explicitly 2017-09-19 18:21:33 +02:00
bpt_helper.c
cc_helper_template.h
cc_helper.c
cpu-qom.h
cpu.c memory: Get rid of address_space_init_shareable 2017-09-22 01:06:51 +02:00
cpu.h Machine/CPU/NUMA queue, 2017-09-19 2017-09-20 17:35:36 +01:00
excp_helper.c
fpu_helper.c
gdbstub.c
hax-all.c
hax-darwin.c
hax-darwin.h
hax-i386.h
hax-interface.h
hax-mem.c General warn report fixups 2017-09-19 14:09:34 +02:00
hax-windows.c
hax-windows.h
helper.c
helper.h
hyperv-proto.h hyperv: add header with protocol definitions 2017-09-19 16:20:49 +02:00
hyperv.c hyperv: add header with protocol definitions 2017-09-19 16:20:49 +02:00
hyperv.h
int_helper.c
kvm_i386.h
kvm-stub.c
kvm.c hyperv: add header with protocol definitions 2017-09-19 16:20:49 +02:00
machine.c migration: pre_save return int 2017-09-27 11:35:59 +01:00
Makefile.objs
mem_helper.c
misc_helper.c
monitor.c target/i386: fix "info mem" for LA57 mode 2017-09-19 16:20:49 +02:00
mpx_helper.c
ops_sse_header.h
ops_sse.h target/i386: fix phminposuw in-place operation 2017-09-19 14:09:11 +02:00
seg_helper.c
shift_helper_template.h
smm_helper.c
svm_helper.c exec,dump,i386,ppc,s390x: don't include exec/cpu-all.h explicitly 2017-09-19 18:21:33 +02:00
svm.h
TODO
trace-events docs: fix broken paths to docs/devel/tracing.txt 2017-07-31 13:12:53 +03:00
translate.c target/i386: trap on instructions longer than >15 bytes 2017-10-16 18:03:53 +02:00
xsave_helper.c