From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753246AbdK1D54 (ORCPT ); Mon, 27 Nov 2017 22:57:56 -0500 Received: from mga09.intel.com ([134.134.136.24]:3762 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751658AbdK1D5z (ORCPT ); Mon, 27 Nov 2017 22:57:55 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,466,1505804400"; d="scan'208";a="6668817" Date: Mon, 27 Nov 2017 19:56:35 -0800 From: Ricardo Neri To: Borislav Petkov Cc: X86 ML , LKML , Kees Cook , Nick Desaulniers Subject: Re: [PATCH] x86/umip: Fix insn_get_code_seg_params()'s return value Message-ID: <20171128035635.GA8145@voyager> References: <20171123091951.1462-1-bp@alien8.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171123091951.1462-1-bp@alien8.de> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 23, 2017 at 10:19:51AM +0100, Borislav Petkov wrote: > From: Borislav Petkov > > 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. > > Signed-off-by: Borislav Petkov > Reported-by: Kees Cook > Reported-by: Nick Desaulniers > Cc: ricardo.neri-calderon@linux.intel.com Thanks Kees and Nick for finding this bug. Thanks Borislav for the quick fix! This change looks OK to me. BR, Ricardo