From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCFC9C07E94 for ; Fri, 4 Jun 2021 12:47:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8D5061418 for ; Fri, 4 Jun 2021 12:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbhFDMt3 convert rfc822-to-8bit (ORCPT ); Fri, 4 Jun 2021 08:49:29 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3155 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbhFDMt2 (ORCPT ); Fri, 4 Jun 2021 08:49:28 -0400 Received: from fraeml711-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FxMnb1tWrz6R20Q; Fri, 4 Jun 2021 20:41:07 +0800 (CST) Received: from fraeml714-chm.china.huawei.com (10.206.15.33) by fraeml711-chm.china.huawei.com (10.206.15.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 4 Jun 2021 14:47:41 +0200 Received: from fraeml714-chm.china.huawei.com ([10.206.15.33]) by fraeml714-chm.china.huawei.com ([10.206.15.33]) with mapi id 15.01.2176.012; Fri, 4 Jun 2021 14:47:41 +0200 From: Roberto Sassu To: Roberto Sassu , kernel test robot CC: "kbuild-all@lists.01.org" , "linux-integrity@vger.kernel.org" , "Mimi Zohar" Subject: RE: [integrity:next-integrity-testing 5/9] security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: incorrect type in assignment (different base types) Thread-Topic: [integrity:next-integrity-testing 5/9] security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: incorrect type in assignment (different base types) Thread-Index: AQHXWRsJfgQoclYuG0mUhYWGxeRPJasDvx7wgAAFNGA= Date: Fri, 4 Jun 2021 12:47:41 +0000 Message-ID: References: <202106041605.ujAVeENC-lkp@intel.com> <860a7b2810ad425cb1175b6ea2f76c08@huawei.com> In-Reply-To: <860a7b2810ad425cb1175b6ea2f76c08@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.48.212.129] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org > From: Roberto Sassu [mailto:roberto.sassu@huawei.com] > Sent: Friday, June 4, 2021 2:00 PM > > From: kernel test robot [mailto:lkp@intel.com] > > Sent: Friday, June 4, 2021 10:23 AM > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux- > > integrity.git next-integrity-testing > > head: d721c15fd519c08819fbc6de39b713e2ed1d9894 > > commit: f8216f6b957f5657c5f4c97f4b037120c6f236bc [5/9] ima: Define new > > template field imode > > config: nios2-randconfig-s031-20210604 (attached as .config) > > compiler: nios2-linux-gcc (GCC) 9.3.0 > > reproduce: > > wget https://raw.githubusercontent.com/intel/lkp- > > tests/master/sbin/make.cross -O ~/bin/make.cross > > chmod +x ~/bin/make.cross > > # apt-get install sparse > > # sparse version: v0.6.3-341-g8af24329-dirty > > # https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux- > > integrity.git/commit/?id=f8216f6b957f5657c5f4c97f4b037120c6f236bc > > git remote add integrity > > https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git > > git fetch --no-tags integrity next-integrity-testing > > git checkout f8216f6b957f5657c5f4c97f4b037120c6f236bc > > # save the attached .config to linux build tree > > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 > > make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 > > ARCH=nios2 > > > > If you fix the issue, kindly add following tag as appropriate > > Reported-by: kernel test robot > > > > > > sparse warnings: (new ones prefixed by >>) > > security/integrity/ima/ima_template_lib.c:100:44: sparse: sparse: cast to > > restricted __le16 > > security/integrity/ima/ima_template_lib.c:107:44: sparse: sparse: cast to > > restricted __le32 > > security/integrity/ima/ima_template_lib.c:114:44: sparse: sparse: cast to > > restricted __le64 > > security/integrity/ima/ima_template_lib.c:135:60: sparse: sparse: > restricted > > __le32 degrades to integer > > security/integrity/ima/ima_template_lib.c:230:49: sparse: sparse: cast to > > restricted __le32 > > security/integrity/ima/ima_template_lib.c:571:28: sparse: sparse: > incorrect > > type in assignment (different base types) @@ expected unsigned int > > [assigned] id @@ got restricted __le16 [usertype] @@ > > security/integrity/ima/ima_template_lib.c:571:28: sparse: expected > > unsigned int [assigned] id > > security/integrity/ima/ima_template_lib.c:571:28: sparse: got restricted > > __le16 [usertype] > > security/integrity/ima/ima_template_lib.c:573:28: sparse: sparse: > incorrect > > type in assignment (different base types) @@ expected unsigned int > > [assigned] id @@ got restricted __le32 [usertype] @@ > > security/integrity/ima/ima_template_lib.c:573:28: sparse: expected > > unsigned int [assigned] id > > security/integrity/ima/ima_template_lib.c:573:28: sparse: got restricted > > __le32 [usertype] > > >> security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: > > incorrect type in assignment (different base types) @@ expected > unsigned > > short [assigned] [usertype] mode @@ got restricted __le16 [usertype] > > @@ > > security/integrity/ima/ima_template_lib.c:616:22: sparse: expected > > unsigned short [assigned] [usertype] mode > > security/integrity/ima/ima_template_lib.c:616:22: sparse: got restricted > > __le16 [usertype] > > > > vim +616 security/integrity/ima/ima_template_lib.c > > > > 599 > > 600 /* > > 601 * ima_eventinodemode_init - include the inode mode as part of the > > template > > 602 * data > > 603 */ > > 604 int ima_eventinodemode_init(struct ima_event_data *event_data, > > 605 struct ima_field_data *field_data) > > 606 { > > 607 struct inode *inode; > > 608 umode_t mode; > > 609 > > 610 if (!event_data->file) > > 611 return 0; > > 612 > > 613 inode = file_inode(event_data->file); > > 614 mode = inode->i_mode; > > 615 if (ima_canonical_fmt) > > > 616 mode = cpu_to_le16(mode); > > int ima_eventinodemode_init(struct ima_event_data *event_data, > struct ima_field_data *field_data) > { > struct inode *inode; > __le16 mode; > > if (!event_data->file) > return 0; > > inode = file_inode(event_data->file); > if (ima_canonical_fmt) > mode = cpu_to_le16(inode->i_mode); > else > mode = (__force __le16)inode->i_mode; > > return ima_write_template_field_data((char *)&mode, > sizeof(mode), > DATA_FMT_UINT, field_data); > } > > Is this correct? Actually not, if ima_canonical_fmt is false, we could still have a big-endian machine. It seems that the warning disappears if I do instead: int ima_eventinodemode_init(struct ima_event_data *event_data, struct ima_field_data *field_data) { struct inode *inode; umode_t mode; if (!event_data->file) return 0; inode = file_inode(event_data->file); mode = inode->i_mode; if (ima_canonical_fmt) cpu_to_le16s(&mode); return ima_write_template_field_data((char *)&mode, sizeof(mode), DATA_FMT_UINT, field_data); } Roberto HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Li Peng, Li Jian, Shi Yanli > Thanks > > Roberto > > HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 > Managing Director: Li Peng, Li Jian, Shi Yanli > > > --- > > 0-DAY CI Kernel Test Service, Intel Corporation > > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4977040238527389281==" MIME-Version: 1.0 From: Roberto Sassu To: kbuild-all@lists.01.org Subject: Re: [integrity:next-integrity-testing 5/9] security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: incorrect type in assignment (different base types) Date: Fri, 04 Jun 2021 12:47:41 +0000 Message-ID: In-Reply-To: <860a7b2810ad425cb1175b6ea2f76c08@huawei.com> List-Id: --===============4977040238527389281== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > From: Roberto Sassu [mailto:roberto.sassu(a)huawei.com] > Sent: Friday, June 4, 2021 2:00 PM > > From: kernel test robot [mailto:lkp(a)intel.com] > > Sent: Friday, June 4, 2021 10:23 AM > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux- > > integrity.git next-integrity-testing > > head: d721c15fd519c08819fbc6de39b713e2ed1d9894 > > commit: f8216f6b957f5657c5f4c97f4b037120c6f236bc [5/9] ima: Define new > > template field imode > > config: nios2-randconfig-s031-20210604 (attached as .config) > > compiler: nios2-linux-gcc (GCC) 9.3.0 > > reproduce: > > wget https://raw.githubusercontent.com/intel/lkp- > > tests/master/sbin/make.cross -O ~/bin/make.cross > > chmod +x ~/bin/make.cross > > # apt-get install sparse > > # sparse version: v0.6.3-341-g8af24329-dirty > > # https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux- > > integrity.git/commit/?id=3Df8216f6b957f5657c5f4c97f4b037120c6f236bc > > git remote add integrity > > https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.g= it > > git fetch --no-tags integrity next-integrity-testing > > git checkout f8216f6b957f5657c5f4c97f4b037120c6f236bc > > # save the attached .config to linux build tree > > COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dgcc-9.3.0 > > make.cross C=3D1 CF=3D'-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=3D1 > > ARCH=3Dnios2 > > > > If you fix the issue, kindly add following tag as appropriate > > Reported-by: kernel test robot > > > > > > sparse warnings: (new ones prefixed by >>) > > security/integrity/ima/ima_template_lib.c:100:44: sparse: sparse: ca= st to > > restricted __le16 > > security/integrity/ima/ima_template_lib.c:107:44: sparse: sparse: ca= st to > > restricted __le32 > > security/integrity/ima/ima_template_lib.c:114:44: sparse: sparse: ca= st to > > restricted __le64 > > security/integrity/ima/ima_template_lib.c:135:60: sparse: sparse: > restricted > > __le32 degrades to integer > > security/integrity/ima/ima_template_lib.c:230:49: sparse: sparse: ca= st to > > restricted __le32 > > security/integrity/ima/ima_template_lib.c:571:28: sparse: sparse: > incorrect > > type in assignment (different base types) @@ expected unsigned int > > [assigned] id @@ got restricted __le16 [usertype] @@ > > security/integrity/ima/ima_template_lib.c:571:28: sparse: expect= ed > > unsigned int [assigned] id > > security/integrity/ima/ima_template_lib.c:571:28: sparse: got re= stricted > > __le16 [usertype] > > security/integrity/ima/ima_template_lib.c:573:28: sparse: sparse: > incorrect > > type in assignment (different base types) @@ expected unsigned int > > [assigned] id @@ got restricted __le32 [usertype] @@ > > security/integrity/ima/ima_template_lib.c:573:28: sparse: expect= ed > > unsigned int [assigned] id > > security/integrity/ima/ima_template_lib.c:573:28: sparse: got re= stricted > > __le32 [usertype] > > >> security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: > > incorrect type in assignment (different base types) @@ expected > unsigned > > short [assigned] [usertype] mode @@ got restricted __le16 [usertype] > > @@ > > security/integrity/ima/ima_template_lib.c:616:22: sparse: expect= ed > > unsigned short [assigned] [usertype] mode > > security/integrity/ima/ima_template_lib.c:616:22: sparse: got re= stricted > > __le16 [usertype] > > > > vim +616 security/integrity/ima/ima_template_lib.c > > > > 599 > > 600 /* > > 601 * ima_eventinodemode_init - include the inode mode as part of = the > > template > > 602 * data > > 603 */ > > 604 int ima_eventinodemode_init(struct ima_event_data *event_data, > > 605 struct ima_field_data *field_data) > > 606 { > > 607 struct inode *inode; > > 608 umode_t mode; > > 609 > > 610 if (!event_data->file) > > 611 return 0; > > 612 > > 613 inode =3D file_inode(event_data->file); > > 614 mode =3D inode->i_mode; > > 615 if (ima_canonical_fmt) > > > 616 mode =3D cpu_to_le16(mode); > = > int ima_eventinodemode_init(struct ima_event_data *event_data, > struct ima_field_data *field_data) > { > struct inode *inode; > __le16 mode; > = > if (!event_data->file) > return 0; > = > inode =3D file_inode(event_data->file); > if (ima_canonical_fmt) > mode =3D cpu_to_le16(inode->i_mode); > else > mode =3D (__force __le16)inode->i_mode; > = > return ima_write_template_field_data((char *)&mode, > sizeof(mode), > DATA_FMT_UINT, field_data); > } > = > Is this correct? Actually not, if ima_canonical_fmt is false, we could still have a big-endi= an machine. It seems that the warning disappears if I do instead: int ima_eventinodemode_init(struct ima_event_data *event_data, struct ima_field_data *field_data) { struct inode *inode; umode_t mode; if (!event_data->file) return 0; inode =3D file_inode(event_data->file); mode =3D inode->i_mode; if (ima_canonical_fmt) cpu_to_le16s(&mode); return ima_write_template_field_data((char *)&mode, sizeof(mode), DATA_FMT_UINT, field_data); } Roberto HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Li Peng, Li Jian, Shi Yanli > Thanks > = > Roberto > = > HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 > Managing Director: Li Peng, Li Jian, Shi Yanli > = > > --- > > 0-DAY CI Kernel Test Service, Intel Corporation > > https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============4977040238527389281==--