x86/insn-eval: negative return value?

From: Kees Cook
Date: Wed Nov 22 2017 - 15:45:22 EST


Hi,

While doing some Clang test builds, this was reported:

arch/x86/lib/insn-eval.c:780:10: warning: implicit conversion from
'int' to 'char' changes value from 132 to -124 [-Wconstant-conversion]
return INSN_CODE_SEG_PARAMS(4, 8);
~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
./arch/x86/include/asm/insn-eval.h:16:57: note: expanded from macro
'INSN_CODE_SEG_PARAMS'
#define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4))
~~~~~~~~^~~~~~~~~~~~~~~~

Is this really expected to wrap negative on IA-32e 64-bit mode case?

Thanks!

-Kees

--
Kees Cook
Pixel Security