[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202211070735.p2WQzNxS-lkp@intel.com>
Date: Mon, 7 Nov 2022 08:00:02 +0800
From: kernel test robot <lkp@...el.com>
To: Jonathan McDowell <noodles@...com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Borislav Petkov <bp@...e.de>, Mimi Zohar <zohar@...ux.ibm.com>
Subject: security/integrity/ima/ima_kexec.c:58:30: sparse: sparse: incorrect
type in assignment (different base types)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 16c7a368c8ba9aba3b0e0ae5ec0a64be9fb45665
commit: b69a2afd5afce9bf6d56e349d6ab592c916e20f2 x86/kexec: Carry forward IMA measurement log on kexec
date: 4 months ago
config: x86_64-randconfig-s051-20221107
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b69a2afd5afce9bf6d56e349d6ab592c916e20f2
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout b69a2afd5afce9bf6d56e349d6ab592c916e20f2
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash security/integrity/ima/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
>> security/integrity/ima/ima_kexec.c:58:30: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] version @@ got restricted __le16 [usertype] @@
security/integrity/ima/ima_kexec.c:58:30: sparse: expected unsigned short [addressable] [assigned] [usertype] version
security/integrity/ima/ima_kexec.c:58:30: sparse: got restricted __le16 [usertype]
>> security/integrity/ima/ima_kexec.c:59:28: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long long [addressable] [assigned] [usertype] count @@ got restricted __le64 [usertype] @@
security/integrity/ima/ima_kexec.c:59:28: sparse: expected unsigned long long [addressable] [assigned] [usertype] count
security/integrity/ima/ima_kexec.c:59:28: sparse: got restricted __le64 [usertype]
>> security/integrity/ima/ima_kexec.c:60:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long long [addressable] [assigned] [usertype] buffer_size @@ got restricted __le64 [usertype] @@
security/integrity/ima/ima_kexec.c:60:34: sparse: expected unsigned long long [addressable] [assigned] [usertype] buffer_size
security/integrity/ima/ima_kexec.c:60:34: sparse: got restricted __le64 [usertype]
vim +58 security/integrity/ima/ima_kexec.c
94c3aac567a9dd Mimi Zohar 2016-12-19 16
7b8589cc29e7c3 Mimi Zohar 2016-12-19 17 #ifdef CONFIG_IMA_KEXEC
7b8589cc29e7c3 Mimi Zohar 2016-12-19 18 static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
7b8589cc29e7c3 Mimi Zohar 2016-12-19 19 unsigned long segment_size)
7b8589cc29e7c3 Mimi Zohar 2016-12-19 20 {
7b8589cc29e7c3 Mimi Zohar 2016-12-19 21 struct ima_queue_entry *qe;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 22 struct seq_file file;
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 23 struct ima_kexec_hdr khdr;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 24 int ret = 0;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 25
7b8589cc29e7c3 Mimi Zohar 2016-12-19 26 /* segment size can't change between kexec load and execute */
7b8589cc29e7c3 Mimi Zohar 2016-12-19 27 file.buf = vmalloc(segment_size);
7b8589cc29e7c3 Mimi Zohar 2016-12-19 28 if (!file.buf) {
7b8589cc29e7c3 Mimi Zohar 2016-12-19 29 ret = -ENOMEM;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 30 goto out;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 31 }
7b8589cc29e7c3 Mimi Zohar 2016-12-19 32
7b8589cc29e7c3 Mimi Zohar 2016-12-19 33 file.size = segment_size;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 34 file.read_pos = 0;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 35 file.count = sizeof(khdr); /* reserved space */
7b8589cc29e7c3 Mimi Zohar 2016-12-19 36
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 37 memset(&khdr, 0, sizeof(khdr));
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 38 khdr.version = 1;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 39 list_for_each_entry_rcu(qe, &ima_measurements, later) {
7b8589cc29e7c3 Mimi Zohar 2016-12-19 40 if (file.count < file.size) {
7b8589cc29e7c3 Mimi Zohar 2016-12-19 41 khdr.count++;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 42 ima_measurements_show(&file, qe);
7b8589cc29e7c3 Mimi Zohar 2016-12-19 43 } else {
7b8589cc29e7c3 Mimi Zohar 2016-12-19 44 ret = -EINVAL;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 45 break;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 46 }
7b8589cc29e7c3 Mimi Zohar 2016-12-19 47 }
7b8589cc29e7c3 Mimi Zohar 2016-12-19 48
7b8589cc29e7c3 Mimi Zohar 2016-12-19 49 if (ret < 0)
7b8589cc29e7c3 Mimi Zohar 2016-12-19 50 goto out;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 51
7b8589cc29e7c3 Mimi Zohar 2016-12-19 52 /*
7b8589cc29e7c3 Mimi Zohar 2016-12-19 53 * fill in reserved space with some buffer details
7b8589cc29e7c3 Mimi Zohar 2016-12-19 54 * (eg. version, buffer size, number of measurements)
7b8589cc29e7c3 Mimi Zohar 2016-12-19 55 */
7b8589cc29e7c3 Mimi Zohar 2016-12-19 56 khdr.buffer_size = file.count;
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 57 if (ima_canonical_fmt) {
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 @58 khdr.version = cpu_to_le16(khdr.version);
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 @59 khdr.count = cpu_to_le64(khdr.count);
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 @60 khdr.buffer_size = cpu_to_le64(khdr.buffer_size);
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 61 }
7b8589cc29e7c3 Mimi Zohar 2016-12-19 62 memcpy(file.buf, &khdr, sizeof(khdr));
d68a6fe9fccfd0 Mimi Zohar 2016-12-19 63
520451e90cbe9d Bruno Meneguele 2021-12-28 64 print_hex_dump_debug("ima dump: ", DUMP_PREFIX_NONE, 16, 1,
520451e90cbe9d Bruno Meneguele 2021-12-28 65 file.buf, file.count < 100 ? file.count : 100,
520451e90cbe9d Bruno Meneguele 2021-12-28 66 true);
7b8589cc29e7c3 Mimi Zohar 2016-12-19 67
7b8589cc29e7c3 Mimi Zohar 2016-12-19 68 *buffer_size = file.count;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 69 *buffer = file.buf;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 70 out:
7b8589cc29e7c3 Mimi Zohar 2016-12-19 71 if (ret == -EINVAL)
7b8589cc29e7c3 Mimi Zohar 2016-12-19 72 vfree(file.buf);
7b8589cc29e7c3 Mimi Zohar 2016-12-19 73 return ret;
7b8589cc29e7c3 Mimi Zohar 2016-12-19 74 }
7b8589cc29e7c3 Mimi Zohar 2016-12-19 75
:::::: The code at line 58 was first introduced by commit
:::::: d68a6fe9fccfd00589c61df672b449d66ba3183f ima: define a canonical binary_runtime_measurements list format
:::::: TO: Mimi Zohar <zohar@...ux.vnet.ibm.com>
:::::: CC: Linus Torvalds <torvalds@...ux-foundation.org>
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (132220 bytes)
Powered by blists - more mailing lists