tree: https://gitee.com/openeuler/kernel.git OLK-6.6 head: 01c2a11a75f4f8b273ef3e34cca3974b10314a3a commit: 5fbe16a682d5af0c2f7145096851e31e3c921d64 [3348/10598] ima: Execute parser to upload digest lists not recognizable by the kernel config: arm64-randconfig-r131-20240707 (https://download.01.org/0day-ci/archive/20240708/202407081457.7NZpgJgk-lkp@i...) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project a0c6b8aef853eedaa0980f07c0a502a5a8a9740e) reproduce: (https://download.01.org/0day-ci/archive/20240708/202407081457.7NZpgJgk-lkp@i...)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot lkp@intel.com | Closes: https://lore.kernel.org/oe-kbuild-all/202407081457.7NZpgJgk-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
security/integrity/ima/ima_digest_list.c:164:37: sparse: sparse: cast to restricted __le16
security/integrity/ima/ima_digest_list.c:165:42: sparse: sparse: cast to restricted __le16 security/integrity/ima/ima_digest_list.c:166:37: sparse: sparse: cast to restricted __le16
security/integrity/ima/ima_digest_list.c:167:38: sparse: sparse: cast to restricted __le32
security/integrity/ima/ima_digest_list.c:168:40: sparse: sparse: cast to restricted __le32
security/integrity/ima/ima_digest_list.c:416:20: sparse: sparse: symbol 'parser_task' was not declared. Should it be static?
vim +164 security/integrity/ima/ima_digest_list.c
b3fef06570ef2b Roberto Sassu 2023-09-12 138 b3fef06570ef2b Roberto Sassu 2023-09-12 139 int ima_parse_compact_list(loff_t size, void *buf, int op) b3fef06570ef2b Roberto Sassu 2023-09-12 140 { b3fef06570ef2b Roberto Sassu 2023-09-12 141 u8 *digest; b3fef06570ef2b Roberto Sassu 2023-09-12 142 void *bufp = buf, *bufendp = buf + size; b3fef06570ef2b Roberto Sassu 2023-09-12 143 struct compact_list_hdr *hdr; b3fef06570ef2b Roberto Sassu 2023-09-12 144 size_t digest_len; b3fef06570ef2b Roberto Sassu 2023-09-12 145 int ret = 0, i; b3fef06570ef2b Roberto Sassu 2023-09-12 146 80701e75d21f48 Roberto Sassu 2023-09-12 147 if (!(ima_digest_list_actions & ima_policy_flag)) 80701e75d21f48 Roberto Sassu 2023-09-12 148 return -EACCES; 80701e75d21f48 Roberto Sassu 2023-09-12 149 b3fef06570ef2b Roberto Sassu 2023-09-12 150 while (bufp < bufendp) { b3fef06570ef2b Roberto Sassu 2023-09-12 151 if (bufp + sizeof(*hdr) > bufendp) { b3fef06570ef2b Roberto Sassu 2023-09-12 152 pr_err("compact list, invalid data\n"); b3fef06570ef2b Roberto Sassu 2023-09-12 153 return -EINVAL; b3fef06570ef2b Roberto Sassu 2023-09-12 154 } b3fef06570ef2b Roberto Sassu 2023-09-12 155 b3fef06570ef2b Roberto Sassu 2023-09-12 156 hdr = bufp; b3fef06570ef2b Roberto Sassu 2023-09-12 157 b3fef06570ef2b Roberto Sassu 2023-09-12 158 if (hdr->version != 1) { b3fef06570ef2b Roberto Sassu 2023-09-12 159 pr_err("compact list, unsupported version\n"); b3fef06570ef2b Roberto Sassu 2023-09-12 160 return -EINVAL; b3fef06570ef2b Roberto Sassu 2023-09-12 161 } b3fef06570ef2b Roberto Sassu 2023-09-12 162 b3fef06570ef2b Roberto Sassu 2023-09-12 163 if (ima_canonical_fmt) { b3fef06570ef2b Roberto Sassu 2023-09-12 @164 hdr->type = le16_to_cpu(hdr->type); b3fef06570ef2b Roberto Sassu 2023-09-12 165 hdr->modifiers = le16_to_cpu(hdr->modifiers); b3fef06570ef2b Roberto Sassu 2023-09-12 166 hdr->algo = le16_to_cpu(hdr->algo); b3fef06570ef2b Roberto Sassu 2023-09-12 @167 hdr->count = le32_to_cpu(hdr->count); b3fef06570ef2b Roberto Sassu 2023-09-12 168 hdr->datalen = le32_to_cpu(hdr->datalen); b3fef06570ef2b Roberto Sassu 2023-09-12 169 } b3fef06570ef2b Roberto Sassu 2023-09-12 170 b3fef06570ef2b Roberto Sassu 2023-09-12 171 if (hdr->algo >= HASH_ALGO__LAST) b3fef06570ef2b Roberto Sassu 2023-09-12 172 return -EINVAL; b3fef06570ef2b Roberto Sassu 2023-09-12 173 b3fef06570ef2b Roberto Sassu 2023-09-12 174 digest_len = hash_digest_size[hdr->algo]; b3fef06570ef2b Roberto Sassu 2023-09-12 175 b3fef06570ef2b Roberto Sassu 2023-09-12 176 if (hdr->type >= COMPACT__LAST) { b3fef06570ef2b Roberto Sassu 2023-09-12 177 pr_err("compact list, invalid type %d\n", hdr->type); b3fef06570ef2b Roberto Sassu 2023-09-12 178 return -EINVAL; b3fef06570ef2b Roberto Sassu 2023-09-12 179 } b3fef06570ef2b Roberto Sassu 2023-09-12 180 b3fef06570ef2b Roberto Sassu 2023-09-12 181 bufp += sizeof(*hdr); b3fef06570ef2b Roberto Sassu 2023-09-12 182 b3fef06570ef2b Roberto Sassu 2023-09-12 183 for (i = 0; i < hdr->count; i++) { b3fef06570ef2b Roberto Sassu 2023-09-12 184 if (bufp + digest_len > bufendp) { b3fef06570ef2b Roberto Sassu 2023-09-12 185 pr_err("compact list, invalid data\n"); b3fef06570ef2b Roberto Sassu 2023-09-12 186 return -EINVAL; b3fef06570ef2b Roberto Sassu 2023-09-12 187 } b3fef06570ef2b Roberto Sassu 2023-09-12 188 b3fef06570ef2b Roberto Sassu 2023-09-12 189 digest = bufp; b3fef06570ef2b Roberto Sassu 2023-09-12 190 bufp += digest_len; b3fef06570ef2b Roberto Sassu 2023-09-12 191 b3fef06570ef2b Roberto Sassu 2023-09-12 192 if (op == DIGEST_LIST_OP_ADD) b3fef06570ef2b Roberto Sassu 2023-09-12 193 ret = ima_add_digest_data_entry(digest, b3fef06570ef2b Roberto Sassu 2023-09-12 194 hdr->algo, hdr->type, hdr->modifiers); b3fef06570ef2b Roberto Sassu 2023-09-12 195 else if (op == DIGEST_LIST_OP_DEL) b3fef06570ef2b Roberto Sassu 2023-09-12 196 ima_del_digest_data_entry(digest, hdr->algo, b3fef06570ef2b Roberto Sassu 2023-09-12 197 hdr->type); b3fef06570ef2b Roberto Sassu 2023-09-12 198 if (ret < 0 && ret != -EEXIST) b3fef06570ef2b Roberto Sassu 2023-09-12 199 return ret; b3fef06570ef2b Roberto Sassu 2023-09-12 200 } b3fef06570ef2b Roberto Sassu 2023-09-12 201 b3fef06570ef2b Roberto Sassu 2023-09-12 202 if (i != hdr->count || b3fef06570ef2b Roberto Sassu 2023-09-12 203 bufp != (void *)hdr + sizeof(*hdr) + hdr->datalen) { b3fef06570ef2b Roberto Sassu 2023-09-12 204 pr_err("compact list, invalid data\n"); b3fef06570ef2b Roberto Sassu 2023-09-12 205 return -EINVAL; b3fef06570ef2b Roberto Sassu 2023-09-12 206 } b3fef06570ef2b Roberto Sassu 2023-09-12 207 } b3fef06570ef2b Roberto Sassu 2023-09-12 208 b3fef06570ef2b Roberto Sassu 2023-09-12 209 return bufp - buf; b3fef06570ef2b Roberto Sassu 2023-09-12 210 } 80701e75d21f48 Roberto Sassu 2023-09-12 211
:::::: The code at line 164 was first introduced by commit :::::: b3fef06570ef2b61dd7181e5c1d128bfcbf6b2ef ima: Add parser of compact digest list
:::::: TO: Roberto Sassu roberto.sassu@huawei.com :::::: CC: zgzxx zhangguangzhi3@huawei.com