20b42789aa
Coverity reported (CID 1450831) an array overrun in
gen_mxu_D16MAX_D16MIN():
1103 } else if (unlikely((XRb == 0) || (XRa == 0))) {
....
1112 if (opc == OPC_MXU_D16MAX) {
1113 tcg_gen_smax_i32(mxu_gpr[XRa - 1], t0, t1);
1114 } else {
1115 tcg_gen_smin_i32(mxu_gpr[XRa - 1], t0, t1);
1116 }
>>> Overrunning array "mxu_gpr" of 15 8-byte elements at element
index 4294967295 (byte offset 34359738367) using index "XRa - 1U"
(which evaluates to 4294967295).
This happens because the code is confused about which of XRa, XRb and
XRc is the output, and which are the inputs. XRa is the output, but
most of the conditions separating out different special cases are
written as if XRc is the output, with the result that we can end up
in the code path that assumes XRa is non-0 even when it is zero.
Fix the erroneous code, bringing it in to line with the structure
used in functions like gen_mxu_S32MAX_S32MIN() and
gen_mxu_Q8MAX_Q8MIN().
Fixes: CID 1450831
Fixes:
|
||
---|---|---|
.. | ||
addr.c | ||
cp0_helper.c | ||
cp0_timer.c | ||
cpu-defs.c.inc | ||
cpu-param.h | ||
cpu-qom.h | ||
cpu.c | ||
cpu.h | ||
dsp_helper.c | ||
fpu_helper.c | ||
fpu_helper.h | ||
gdbstub.c | ||
helper.h | ||
internal.h | ||
kvm_mips.h | ||
kvm.c | ||
lmmi_helper.c | ||
machine.c | ||
meson.build | ||
mips32r6.decode | ||
mips64r6.decode | ||
mips-defs.h | ||
mips-semi.c | ||
msa32.decode | ||
msa64.decode | ||
msa_helper.c | ||
msa_helper.h.inc | ||
msa_translate.c | ||
mxu_translate.c | ||
op_helper.c | ||
rel6_translate.c | ||
tlb_helper.c | ||
TODO | ||
trace-events | ||
trace.h | ||
translate_addr_const.c | ||
translate.c | ||
translate.h | ||
tx79_translate.c | ||
tx79.decode | ||
txx9_translate.c |