]> git.itanic.dy.fi Git - linux-stable/commitdiff
x86/umip: Fix insn_get_code_seg_params()'s return value
authorBorislav Petkov <bp@suse.de>
Thu, 23 Nov 2017 09:19:51 +0000 (10:19 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 23 Nov 2017 19:17:59 +0000 (20:17 +0100)
In order to save on redundant structs definitions
insn_get_code_seg_params() was made to return two 4-bit values in a char
but clang complains:

  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))

Those two values do get picked apart afterwards the opposite way of how
they were ORed so wrt to the LSByte, the return value is the same.

But this function returns -EINVAL in the error case, which is an int. So
make it return an int which is the native word size anyway and thus fix
the clang warning.

Reported-by: Kees Cook <keescook@google.com>
Reported-by: Nick Desaulniers <nick.desaulniers@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: ricardo.neri-calderon@linux.intel.com
Link: https://lkml.kernel.org/r/20171123091951.1462-1-bp@alien8.de
arch/x86/include/asm/insn-eval.h
arch/x86/kernel/umip.c
arch/x86/lib/insn-eval.c

index e1d3b4ce8a925350df55f898dbdb9cf0f416881f..2b6ccf2c49f11c9c54fbe448ea7d33d997b99ca6 100644 (file)
@@ -18,6 +18,6 @@
 void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs);
 int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs);
 unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
-char insn_get_code_seg_params(struct pt_regs *regs);
+int insn_get_code_seg_params(struct pt_regs *regs);
 
 #endif /* _ASM_X86_INSN_EVAL_H */
index dabbac30acdff563c74ca245cac6ed9a8a07216b..f44ce0fb35832aa0cfd7619fff7ad27b1742540e 100644 (file)
@@ -319,7 +319,7 @@ bool fixup_umip_exception(struct pt_regs *regs)
        unsigned char buf[MAX_INSN_SIZE];
        void __user *uaddr;
        struct insn insn;
-       char seg_defs;
+       int seg_defs;
 
        if (!regs)
                return false;
index 35625d279458f478b7d14ea47461e8a085924b13..9119d8e41f1ff59e2c8584a36f0f03d000bb1bbe 100644 (file)
@@ -733,11 +733,11 @@ static unsigned long get_seg_limit(struct pt_regs *regs, int seg_reg_idx)
  *
  * Returns:
  *
- * A signed 8-bit value containing the default parameters on success.
+ * An int containing ORed-in default parameters on success.
  *
  * -EINVAL on error.
  */
-char insn_get_code_seg_params(struct pt_regs *regs)
+int insn_get_code_seg_params(struct pt_regs *regs)
 {
        struct desc_struct *desc;
        short sel;