qemu-cr16/target
Peter Maydell 4f503afc7e target/x86: Correctly handle invalid 0x0f 0xc7 0xxx insns
In the decode_group9() function, if we don't recognise the insn as
one that we should handle, we leave the 'entry' pointer unaltered.
Because the X86OpEntry struct has a union for the gen and decode
pointers, this means that the top level code will call decode.e.gen()
which tries to use the decode function pointer (still set to
decode_group9) as a gen function pointer.

This is undefined behaviour, but seems to be mostly harmless in
practice (we call decode_group9() again with bogus arguments and it
does nothing).  If you have CFI enabled then it will trip the CFI
check:

../target/i386/tcg/decode-new.c.inc:2862:9: runtime error: control flow integrity check for type 'void (struct DisasContext *, struct X86DecodedInsn *)' failed during indirect function call

Set *entry to UNKNOWN_OPCODE to provoke the #UD exception, as we do
in decode_group1A() and decode_group11() for similar situations.

Thanks to the bug reporter for the clear description and analysis of
the bug and the simple reproducer.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3172
Fixes: fcd16539eb ("target/i386: convert CMPXCHG8B/CMPXCHG16B to new decoder")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20251021173152.1695997-1-peter.maydell@linaro.org>
2025-11-10 12:02:45 +01:00
..
alpha target/alpha: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
arm target-arm queue: 2025-11-01 10:52:48 +01:00
avr target/avr: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
hexagon target/hexagon: Only indent on linux 2025-10-17 13:45:46 -07:00
hppa target/hppa: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
i386 target/x86: Correctly handle invalid 0x0f 0xc7 0xxx insns 2025-11-10 12:02:45 +01:00
loongarch loongarch queue 2025-10-31 12:55:44 +01:00
m68k target/m68k: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
microblaze maintainer updates for 10.2 2025-10-30 09:25:15 +01:00
mips target/mips: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
openrisc target/openrisc: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
ppc ppc queue for 10.2 2025-11-01 09:39:10 +01:00
riscv target/riscv: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
rx rx: cpu: fix interrupts check in rx_cpu_do_interrupt() 2025-11-03 14:15:57 +01:00
s390x target/s390x: Use address generation for register branch targets 2025-11-03 08:27:59 +01:00
sh4 target/sh4: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
sparc target/sparc: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
tricore target/tricore: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
xtensa target/xtensa: call plugin trap callbacks 2025-10-29 14:12:43 +00:00
Kconfig target/cris: Remove the deprecated CRIS target 2024-09-13 20:11:13 +02:00
meson.build target/cris: Remove the deprecated CRIS target 2024-09-13 20:11:13 +02:00