Skip to content

Commit e2a5dca

Browse files
suryasaimadhuKAGA-KOKO
authored andcommitted
x86/umip: Fix insn_get_code_seg_params()'s return value
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 <[email protected]> Reported-by: Nick Desaulniers <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 69550d4 commit e2a5dca

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

arch/x86/include/asm/insn-eval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs);
1919
int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs);
2020
unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
21-
char insn_get_code_seg_params(struct pt_regs *regs);
21+
int insn_get_code_seg_params(struct pt_regs *regs);
2222

2323
#endif /* _ASM_X86_INSN_EVAL_H */

arch/x86/kernel/umip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ bool fixup_umip_exception(struct pt_regs *regs)
319319
unsigned char buf[MAX_INSN_SIZE];
320320
void __user *uaddr;
321321
struct insn insn;
322-
char seg_defs;
322+
int seg_defs;
323323

324324
if (!regs)
325325
return false;

arch/x86/lib/insn-eval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,11 +733,11 @@ static unsigned long get_seg_limit(struct pt_regs *regs, int seg_reg_idx)
733733
*
734734
* Returns:
735735
*
736-
* A signed 8-bit value containing the default parameters on success.
736+
* An int containing ORed-in default parameters on success.
737737
*
738738
* -EINVAL on error.
739739
*/
740-
char insn_get_code_seg_params(struct pt_regs *regs)
740+
int insn_get_code_seg_params(struct pt_regs *regs)
741741
{
742742
struct desc_struct *desc;
743743
short sel;

0 commit comments

Comments
 (0)