CC: [email protected] BCC: [email protected] CC: "GNU/Weeb Mailing List" <[email protected]> CC: [email protected] TO: Roberto Sassu <[email protected]> CC: Alexei Starovoitov <[email protected]> CC: Mimi Zohar <[email protected]>
tree: https://github.com/ammarfaizi2/linux-block bpf/bpf-next/master head: ad13baf4569152b00de11949b8c93aaa83c1243f commit: 280fe8367b0dc45b6ac5e04fad03e16e99540c0c [170/201] ima: Always return a file measurement in ima_file_hash() :::::: branch date: 31 hours ago :::::: commit date: 7 days ago config: x86_64-rhel-8.3-kselftests (https://download.01.org/0day-ci/archive/20220318/[email protected]/config) compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Julia Lawall <[email protected]> cocci warnings: (new ones prefixed by >>) >> security/integrity/ima/ima_main.c:546:3-9: preceding lock on line 532 >> security/integrity/ima/ima_main.c:546:3-9: preceding lock on line 532 security/integrity/ima/ima_main.c:553:2-8: preceding lock on line 532 security/integrity/ima/ima_main.c:553:2-8: preceding lock on line 549 vim +546 security/integrity/ima/ima_main.c 8eb988c70e7709 Mimi Zohar 2010-01-20 522 280fe8367b0dc4 Roberto Sassu 2022-03-02 523 static int __ima_inode_hash(struct inode *inode, struct file *file, char *buf, 280fe8367b0dc4 Roberto Sassu 2022-03-02 524 size_t buf_size) 6beea7afcc72b8 Florent Revest 2020-01-13 525 { 280fe8367b0dc4 Roberto Sassu 2022-03-02 526 struct integrity_iint_cache *iint = NULL, tmp_iint; 280fe8367b0dc4 Roberto Sassu 2022-03-02 527 int rc, hash_algo; 6beea7afcc72b8 Florent Revest 2020-01-13 528 280fe8367b0dc4 Roberto Sassu 2022-03-02 529 if (ima_policy_flag) { 6beea7afcc72b8 Florent Revest 2020-01-13 530 iint = integrity_iint_find(inode); 280fe8367b0dc4 Roberto Sassu 2022-03-02 531 if (iint) 280fe8367b0dc4 Roberto Sassu 2022-03-02 @532 mutex_lock(&iint->mutex); 280fe8367b0dc4 Roberto Sassu 2022-03-02 533 } 280fe8367b0dc4 Roberto Sassu 2022-03-02 534 280fe8367b0dc4 Roberto Sassu 2022-03-02 535 if ((!iint || !(iint->flags & IMA_COLLECTED)) && file) { 280fe8367b0dc4 Roberto Sassu 2022-03-02 536 if (iint) 280fe8367b0dc4 Roberto Sassu 2022-03-02 537 mutex_unlock(&iint->mutex); 280fe8367b0dc4 Roberto Sassu 2022-03-02 538 280fe8367b0dc4 Roberto Sassu 2022-03-02 539 memset(&tmp_iint, 0, sizeof(tmp_iint)); 280fe8367b0dc4 Roberto Sassu 2022-03-02 540 tmp_iint.inode = inode; 280fe8367b0dc4 Roberto Sassu 2022-03-02 541 mutex_init(&tmp_iint.mutex); 280fe8367b0dc4 Roberto Sassu 2022-03-02 542 280fe8367b0dc4 Roberto Sassu 2022-03-02 543 rc = ima_collect_measurement(&tmp_iint, file, NULL, 0, 280fe8367b0dc4 Roberto Sassu 2022-03-02 544 ima_hash_algo, NULL); 280fe8367b0dc4 Roberto Sassu 2022-03-02 545 if (rc < 0) 6beea7afcc72b8 Florent Revest 2020-01-13 @546 return -EOPNOTSUPP; 6beea7afcc72b8 Florent Revest 2020-01-13 547 280fe8367b0dc4 Roberto Sassu 2022-03-02 548 iint = &tmp_iint; 6beea7afcc72b8 Florent Revest 2020-01-13 549 mutex_lock(&iint->mutex); 280fe8367b0dc4 Roberto Sassu 2022-03-02 550 } 280fe8367b0dc4 Roberto Sassu 2022-03-02 551 280fe8367b0dc4 Roberto Sassu 2022-03-02 552 if (!iint) 280fe8367b0dc4 Roberto Sassu 2022-03-02 553 return -EOPNOTSUPP; aa662fc04f5b29 KP Singh 2020-09-16 554 aa662fc04f5b29 KP Singh 2020-09-16 555 /* aa662fc04f5b29 KP Singh 2020-09-16 556 * ima_file_hash can be called when ima_collect_measurement has still aa662fc04f5b29 KP Singh 2020-09-16 557 * not been called, we might not always have a hash. aa662fc04f5b29 KP Singh 2020-09-16 558 */ aa662fc04f5b29 KP Singh 2020-09-16 559 if (!iint->ima_hash) { aa662fc04f5b29 KP Singh 2020-09-16 560 mutex_unlock(&iint->mutex); aa662fc04f5b29 KP Singh 2020-09-16 561 return -EOPNOTSUPP; aa662fc04f5b29 KP Singh 2020-09-16 562 } aa662fc04f5b29 KP Singh 2020-09-16 563 6beea7afcc72b8 Florent Revest 2020-01-13 564 if (buf) { 6beea7afcc72b8 Florent Revest 2020-01-13 565 size_t copied_size; 6beea7afcc72b8 Florent Revest 2020-01-13 566 6beea7afcc72b8 Florent Revest 2020-01-13 567 copied_size = min_t(size_t, iint->ima_hash->length, buf_size); 6beea7afcc72b8 Florent Revest 2020-01-13 568 memcpy(buf, iint->ima_hash->digest, copied_size); 6beea7afcc72b8 Florent Revest 2020-01-13 569 } 6beea7afcc72b8 Florent Revest 2020-01-13 570 hash_algo = iint->ima_hash->algo; 6beea7afcc72b8 Florent Revest 2020-01-13 571 mutex_unlock(&iint->mutex); 6beea7afcc72b8 Florent Revest 2020-01-13 572 280fe8367b0dc4 Roberto Sassu 2022-03-02 573 if (iint == &tmp_iint) 280fe8367b0dc4 Roberto Sassu 2022-03-02 574 kfree(iint->ima_hash); 280fe8367b0dc4 Roberto Sassu 2022-03-02 575 6beea7afcc72b8 Florent Revest 2020-01-13 576 return hash_algo; 6beea7afcc72b8 Florent Revest 2020-01-13 577 } 403319be5de511 KP Singh 2020-11-24 578 :::::: The code at line 546 was first introduced by commit :::::: 6beea7afcc72b86986080ea1d228a42f2000f2a9 ima: add the ability to query the cached hash of a given file :::::: TO: Florent Revest <[email protected]> :::::: CC: Mimi Zohar <[email protected]> --- 0-DAY CI Kernel Test Service https://lists.01.org/hyperkitty/list/[email protected] _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
