CC: kbuild-all(a)lists.01.org In-Reply-To: <20200824061712.195654-2-ebiggers@kernel.org> References: <20200824061712.195654-2-ebiggers@kernel.org> TO: Eric Biggers Hi Eric, [FYI, it's a private test report for your RFC patch.] [auto build test WARNING on f2fs/dev-test] [also build test WARNING on linus/master v5.9-rc2 next-20200824] [cannot apply to ext4/dev rw-ubifs/next rw-ubifs/fixes] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Eric-Biggers/fscrypt-avoid-GFP_NOFS-unsafe-key-setup-during-transaction/20200824-141936 base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test :::::: branch date: 14 hours ago :::::: commit date: 14 hours ago config: mips-randconfig-m031-20200824 (attached as .config) compiler: mipsel-linux-gcc (GCC) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot Reported-by: Dan Carpenter smatch warnings: fs/crypto/keysetup.c:490 fscrypt_setup_encryption_info() warn: passing a valid pointer to 'PTR_ERR' # https://github.com/0day-ci/linux/commit/e83d6a405416ac7c2a5836a3b027837ceb4a3255 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Eric-Biggers/fscrypt-avoid-GFP_NOFS-unsafe-key-setup-during-transaction/20200824-141936 git checkout e83d6a405416ac7c2a5836a3b027837ceb4a3255 vim +/PTR_ERR +490 fs/crypto/keysetup.c 8094c3ceb21ad9 fs/crypto/keyinfo.c Eric Biggers 2019-01-06 469 e83d6a405416ac fs/crypto/keysetup.c Eric Biggers 2020-08-23 470 static int e83d6a405416ac fs/crypto/keysetup.c Eric Biggers 2020-08-23 471 fscrypt_setup_encryption_info(struct inode *inode, e83d6a405416ac fs/crypto/keysetup.c Eric Biggers 2020-08-23 472 const union fscrypt_policy *policy, e83d6a405416ac fs/crypto/keysetup.c Eric Biggers 2020-08-23 473 const u8 nonce[FSCRYPT_FILE_NONCE_SIZE]) 26bf3dc7e25b81 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-05-19 474 { 0b81d077907269 fs/crypto/keyinfo.c Jaegeuk Kim 2015-05-15 475 struct fscrypt_info *crypt_info; e1cc40e5d42acb fs/crypto/keyinfo.c Eric Biggers 2018-05-18 476 struct fscrypt_mode *mode; b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 477 struct key *master_key = NULL; 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 478 int res; 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 479 8094c3ceb21ad9 fs/crypto/keyinfo.c Eric Biggers 2019-01-06 480 crypt_info = kmem_cache_zalloc(fscrypt_info_cachep, GFP_NOFS); 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 481 if (!crypt_info) 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 482 return -ENOMEM; 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 483 59dc6a8e1f534c fs/crypto/keyinfo.c Eric Biggers 2019-08-04 484 crypt_info->ci_inode = inode; e83d6a405416ac fs/crypto/keysetup.c Eric Biggers 2020-08-23 485 crypt_info->ci_policy = *policy; e83d6a405416ac fs/crypto/keysetup.c Eric Biggers 2020-08-23 486 memcpy(crypt_info->ci_nonce, nonce, FSCRYPT_FILE_NONCE_SIZE); 640778fbc97b36 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-05-12 487 5dae460c2292db fs/crypto/keysetup.c Eric Biggers 2019-08-04 488 mode = select_encryption_mode(&crypt_info->ci_policy, inode); e1cc40e5d42acb fs/crypto/keyinfo.c Eric Biggers 2018-05-18 489 if (IS_ERR(mode)) { e1cc40e5d42acb fs/crypto/keyinfo.c Eric Biggers 2018-05-18 @490 res = PTR_ERR(mode); 26bf3dc7e25b81 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-05-19 491 goto out; e1cc40e5d42acb fs/crypto/keyinfo.c Eric Biggers 2018-05-18 492 } 8094c3ceb21ad9 fs/crypto/keyinfo.c Eric Biggers 2019-01-06 493 WARN_ON(mode->ivsize > FSCRYPT_MAX_IV_SIZE); 8094c3ceb21ad9 fs/crypto/keyinfo.c Eric Biggers 2019-01-06 494 crypt_info->ci_mode = mode; 8f39850dffa9cb fs/crypto/keyinfo.c Eric Biggers 2016-09-15 495 b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 496 res = setup_file_encryption_key(crypt_info, &master_key); 26bf3dc7e25b81 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-05-19 497 if (res) 26bf3dc7e25b81 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-05-19 498 goto out; 26bf3dc7e25b81 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-05-19 499 ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 500 /* ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 501 * Multiple tasks may race to set ->i_crypt_info, so use ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 502 * cmpxchg_release(). This pairs with the smp_load_acquire() in ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 503 * fscrypt_get_info(). I.e., here we publish ->i_crypt_info with a ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 504 * RELEASE barrier so that other tasks can ACQUIRE it. ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 505 */ b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 506 if (cmpxchg_release(&inode->i_crypt_info, NULL, crypt_info) == NULL) { ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 507 /* ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 508 * We won the race and set ->i_crypt_info to our crypt_info. ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 509 * Now link it into the master key's inode list. ab673b987488c4 fs/crypto/keysetup.c Eric Biggers 2020-07-21 510 */ b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 511 if (master_key) { b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 512 struct fscrypt_master_key *mk = b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 513 master_key->payload.data[0]; b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 514 b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 515 refcount_inc(&mk->mk_refcount); b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 516 crypt_info->ci_master_key = key_get(master_key); b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 517 spin_lock(&mk->mk_decrypted_inodes_lock); b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 518 list_add(&crypt_info->ci_master_key_link, b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 519 &mk->mk_decrypted_inodes); b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 520 spin_unlock(&mk->mk_decrypted_inodes_lock); b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 521 } 1b53cf9815bb47 fs/crypto/keyinfo.c Eric Biggers 2017-02-21 522 crypt_info = NULL; b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 523 } b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 524 res = 0; 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 525 out: b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 526 if (master_key) { 23c688b54016ee fs/crypto/keysetup.c Eric Biggers 2019-08-04 527 struct fscrypt_master_key *mk = master_key->payload.data[0]; 23c688b54016ee fs/crypto/keysetup.c Eric Biggers 2019-08-04 528 23c688b54016ee fs/crypto/keysetup.c Eric Biggers 2019-08-04 529 up_read(&mk->mk_secret_sem); b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 530 key_put(master_key); b1c0ec3599f42a fs/crypto/keysetup.c Eric Biggers 2019-08-04 531 } 0b81d077907269 fs/crypto/keyinfo.c Jaegeuk Kim 2015-05-15 532 if (res == -ENOKEY) 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 533 res = 0; 0b81d077907269 fs/crypto/keyinfo.c Jaegeuk Kim 2015-05-15 534 put_crypt_info(crypt_info); 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 535 return res; 0adda907f23df2 fs/f2fs/crypto_key.c Jaegeuk Kim 2015-04-21 536 } e83d6a405416ac fs/crypto/keysetup.c Eric Biggers 2020-08-23 537 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org