Hi Sweet, kernel test robot noticed the following build warnings: url: https://github.com/intel-lab-lkp/linux/commits/Sweet-Tea-Dorminy/fscrypt-move-inline-crypt-decision-to-info-setup/20230809-030251 base: 54d2161835d828a9663f548f61d1d9c3d3482122 patch link: https://lore.kernel.org/r/64c47243cea5a8eca15538b51f88c0a6d53799cf.1691505830.git.sweettea-kernel%40dorminy.me patch subject: [PATCH v6 8/8] fscrypt: make prepared keys record their type config: x86_64-randconfig-m001-20230808 (https://download.01.org/0day-ci/archive/20230809/202308092324.d0OCNA1O-lkp@xxxxxxxxx/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230809/202308092324.d0OCNA1O-lkp@xxxxxxxxx/reproduce) 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@xxxxxxxxx> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> | Closes: https://lore.kernel.org/r/202308092324.d0OCNA1O-lkp@xxxxxxxxx/ smatch warnings: fs/crypto/keysetup.c:300 setup_new_mode_prepared_key() warn: inconsistent returns '&fscrypt_mode_key_setup_mutex'. vim +300 fs/crypto/keysetup.c a03cf25a20f748 Sweet Tea Dorminy 2023-08-08 238 static int setup_new_mode_prepared_key(struct fscrypt_master_key *mk, a03cf25a20f748 Sweet Tea Dorminy 2023-08-08 239 struct fscrypt_prepared_key *prep_key, 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 240 const struct fscrypt_info *ci) 5dae460c2292db Eric Biggers 2019-08-04 241 { b103fb7653fff0 Eric Biggers 2019-10-24 242 const struct inode *inode = ci->ci_inode; b103fb7653fff0 Eric Biggers 2019-10-24 243 const struct super_block *sb = inode->i_sb; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 244 unsigned int policy_flags = fscrypt_policy_flags(&ci->ci_policy); 5dae460c2292db Eric Biggers 2019-08-04 245 struct fscrypt_mode *mode = ci->ci_mode; 85af90e57ce969 Eric Biggers 2019-12-09 246 const u8 mode_num = mode - fscrypt_modes; 5dae460c2292db Eric Biggers 2019-08-04 247 u8 mode_key[FSCRYPT_MAX_KEY_SIZE]; b103fb7653fff0 Eric Biggers 2019-10-24 248 u8 hkdf_info[sizeof(mode_num) + sizeof(sb->s_uuid)]; b103fb7653fff0 Eric Biggers 2019-10-24 249 unsigned int hkdf_infolen = 0; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 250 u8 hkdf_context = 0; a03cf25a20f748 Sweet Tea Dorminy 2023-08-08 251 int err = 0; e3b1078bedd323 Eric Biggers 2020-05-15 252 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 253 switch (policy_flags & FSCRYPT_POLICY_FLAGS_KEY_MASK) { 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 254 case FSCRYPT_POLICY_FLAG_DIRECT_KEY: 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 255 hkdf_context = HKDF_CONTEXT_DIRECT_KEY; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 256 break; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 257 case FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64: 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 258 hkdf_context = HKDF_CONTEXT_IV_INO_LBLK_64_KEY; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 259 break; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 260 case FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32: 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 261 hkdf_context = HKDF_CONTEXT_IV_INO_LBLK_32_KEY; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 262 break; 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 263 } 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 264 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 265 /* 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 266 * For DIRECT_KEY policies: instead of deriving per-file encryption 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 267 * keys, the per-file nonce will be included in all the IVs. But 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 268 * unlike v1 policies, for v2 policies in this case we don't encrypt 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 269 * with the master key directly but rather derive a per-mode encryption 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 270 * key. This ensures that the master key is consistently used only for 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 271 * HKDF, avoiding key reuse issues. 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 272 * 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 273 * For IV_INO_LBLK policies: encryption keys are derived from 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 274 * (master_key, mode_num, filesystem_uuid), and inode number is 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 275 * included in the IVs. This format is optimized for use with inline 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 276 * encryption hardware compliant with the UFS standard. 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 277 */ 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 278 e3b1078bedd323 Eric Biggers 2020-05-15 279 mutex_lock(&fscrypt_mode_key_setup_mutex); e3b1078bedd323 Eric Biggers 2020-05-15 280 5fee36095cda45 Satya Tangirala 2020-07-02 281 if (fscrypt_is_key_prepared(prep_key, ci)) a03cf25a20f748 Sweet Tea Dorminy 2023-08-08 282 goto out_unlock; 5dae460c2292db Eric Biggers 2019-08-04 283 5dae460c2292db Eric Biggers 2019-08-04 284 BUILD_BUG_ON(sizeof(mode_num) != 1); b103fb7653fff0 Eric Biggers 2019-10-24 285 BUILD_BUG_ON(sizeof(sb->s_uuid) != 16); 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 286 BUILD_BUG_ON(sizeof(hkdf_info) != MAX_MODE_KEY_HKDF_INFO_SIZE); 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 287 hkdf_infolen = fill_hkdf_info_for_mode_key(ci, hkdf_info); 78265b33a56a52 Sweet Tea Dorminy 2023-08-08 288 5dae460c2292db Eric Biggers 2019-08-04 289 err = fscrypt_hkdf_expand(&mk->mk_secret.hkdf, b103fb7653fff0 Eric Biggers 2019-10-24 290 hkdf_context, hkdf_info, hkdf_infolen, 5dae460c2292db Eric Biggers 2019-08-04 291 mode_key, mode->keysize); 5dae460c2292db Eric Biggers 2019-08-04 292 if (err) 3bd6d42474f3a9 Sweet Tea Dorminy 2023-08-08 293 return err; Originally this was goto out_unlock; Not sure why it was changed to a direct return. 3bd6d42474f3a9 Sweet Tea Dorminy 2023-08-08 294 prep_key->type = FSCRYPT_KEY_MASTER_KEY; 5fee36095cda45 Satya Tangirala 2020-07-02 295 err = fscrypt_prepare_key(prep_key, mode_key, ci); 5dae460c2292db Eric Biggers 2019-08-04 296 memzero_explicit(mode_key, mode->keysize); a03cf25a20f748 Sweet Tea Dorminy 2023-08-08 297 e3b1078bedd323 Eric Biggers 2020-05-15 298 out_unlock: e3b1078bedd323 Eric Biggers 2020-05-15 299 mutex_unlock(&fscrypt_mode_key_setup_mutex); e3b1078bedd323 Eric Biggers 2020-05-15 @300 return err; 5dae460c2292db Eric Biggers 2019-08-04 301 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki