* [integrity:next-integrity-testing 5/9] security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: incorrect type in assignment (different base types)
@ 2021-06-04 8:23 ` kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-06-04 8:23 UTC (permalink / raw)
To: Roberto Sassu; +Cc: kbuild-all, linux-integrity, Mimi Zohar
[-- Attachment #1: Type: text/plain, Size: 3712 bytes --]
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 <lkp@intel.com>
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);
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 21406 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [integrity:next-integrity-testing 5/9] security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: incorrect type in assignment (different base types)
@ 2021-06-04 8:23 ` kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-06-04 8:23 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3775 bytes --]
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 <lkp@intel.com>
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);
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 21406 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* 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)
2021-06-04 8:23 ` kernel test robot
@ 2021-06-04 12:00 ` Roberto Sassu
-1 siblings, 0 replies; 6+ messages in thread
From: Roberto Sassu @ 2021-06-04 12:00 UTC (permalink / raw)
To: kernel test robot; +Cc: kbuild-all, linux-integrity, Mimi Zohar
> 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 <lkp@intel.com>
>
>
> 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?
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* 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)
@ 2021-06-04 12:00 ` Roberto Sassu
0 siblings, 0 replies; 6+ messages in thread
From: Roberto Sassu @ 2021-06-04 12:00 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 4656 bytes --]
> 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=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 <lkp@intel.com>
>
>
> 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?
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* 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)
2021-06-04 12:00 ` Roberto Sassu
@ 2021-06-04 12:47 ` Roberto Sassu
-1 siblings, 0 replies; 6+ messages in thread
From: Roberto Sassu @ 2021-06-04 12:47 UTC (permalink / raw)
To: Roberto Sassu, kernel test robot; +Cc: kbuild-all, linux-integrity, Mimi Zohar
> 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 <lkp@intel.com>
> >
> >
> > 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* 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)
@ 2021-06-04 12:47 ` Roberto Sassu
0 siblings, 0 replies; 6+ messages in thread
From: Roberto Sassu @ 2021-06-04 12:47 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 5671 bytes --]
> 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=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 <lkp@intel.com>
> >
> >
> > 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(a)lists.01.org
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-04 12:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 8:23 [integrity:next-integrity-testing 5/9] security/integrity/ima/ima_template_lib.c:616:22: sparse: sparse: incorrect type in assignment (different base types) kernel test robot
2021-06-04 8:23 ` kernel test robot
2021-06-04 12:00 ` Roberto Sassu
2021-06-04 12:00 ` Roberto Sassu
2021-06-04 12:47 ` Roberto Sassu
2021-06-04 12:47 ` Roberto Sassu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.