All of lore.kernel.org
 help / color / mirror / Atom feed
* [meghadey-crypto:crypto-avx512 5/6] arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
@ 2021-10-01 14:39 kernel test robot
  2021-10-10 10:13   ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2021-10-01 14:39 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 26832 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Megha Dey <megha.dey@intel.com>
CC: Tomasz Kantecki <tomasz.kantecki@intel.com>

tree:   https://github.com/meghadey/crypto crypto-avx512
head:   9c8c2ca77f6e2575a130bddb9767d068e1162d71
commit: 377aede9f10ee28be954473668bc6d33c6c9db75 [5/6] crypto: aesni - AVX512 version of AESNI-GCM using VPCLMULQDQ
:::::: branch date: 9 days ago
:::::: commit date: 9 days ago
config: x86_64-randconfig-c007-20210930 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 962e503cc8bc411f7523cc393acae8aae425b1c4)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/meghadey/crypto/commit/377aede9f10ee28be954473668bc6d33c6c9db75
        git remote add meghadey-crypto https://github.com/meghadey/crypto
        git fetch --no-tags meghadey-crypto crypto-avx512
        git checkout 377aede9f10ee28be954473668bc6d33c6c9db75
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                                             ^
   include/linux/compiler.h:33:34: note: expanded from macro '__branch_check__'
                           ______r = __builtin_expect(!!(x), expect);      \
                                                         ^
   security/keys/keyring.c:1302:20: note: Field 'desc_len' is not equal to 0
           BUG_ON(index_key->desc_len == 0);
                             ^
   security/keys/keyring.c:1302:2: note: Taking false branch
           BUG_ON(index_key->desc_len == 0);
           ^
   include/asm-generic/bug.h:65:32: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                  ^
   security/keys/keyring.c:1302:2: note: Loop condition is false.  Exiting loop
           BUG_ON(index_key->desc_len == 0);
           ^
   include/asm-generic/bug.h:65:27: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                             ^
   security/keys/keyring.c:1303:2: note: Taking false branch
           BUG_ON(*_edit != NULL);
           ^
   include/asm-generic/bug.h:65:32: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                  ^
   security/keys/keyring.c:1303:2: note: Loop condition is false.  Exiting loop
           BUG_ON(*_edit != NULL);
           ^
   include/asm-generic/bug.h:65:27: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                             ^
   security/keys/keyring.c:1305:2: note: Null pointer value stored to 'to_edit'
           *_edit = NULL;
           ^~~~~~~~~~~~~
   security/keys/keyring.c:1308:6: note: Assuming the condition is false
           if (test_bit(KEY_FLAG_REVOKED, &keyring->flags))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   security/keys/keyring.c:1308:2: note: Taking false branch
           if (test_bit(KEY_FLAG_REVOKED, &keyring->flags))
           ^
   security/keys/keyring.c:1318:2: note: Taking true branch
           if (IS_ERR(edit)) {
           ^
   security/keys/keyring.c:1320:3: note: Control jumps to line 1340
                   goto error;
                   ^
   security/keys/keyring.c:1340:2: note: Taking false branch
           kleave(" = %d", ret);
           ^
   security/keys/internal.h:36:2: note: expanded from macro 'kleave'
           no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
           ^
   include/linux/printk.h:131:2: note: expanded from macro 'no_printk'
           if (0)                                          \
           ^
   security/keys/keyring.c:1613:8: note: Returning from '__key_link_begin'
           ret = __key_link_begin(to_keyring, &key->index_key, &to_edit);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   security/keys/keyring.c:1614:6: note: Assuming 'ret' is >= 0
           if (ret < 0)
               ^~~~~~~
   security/keys/keyring.c:1614:2: note: Taking false branch
           if (ret < 0)
           ^
   security/keys/keyring.c:1618:6: note: Access to field 'dead_leaf' results in a dereference of a null pointer (loaded from variable 'to_edit')
           if (to_edit->dead_leaf && (flags & KEYCTL_MOVE_EXCL))
               ^~~~~~~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
>> arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN);
                                    ^~~~
   arch/x86/crypto/aesni-intel_glue.c:683:27: note: Value stored to 'data' during its initialization is never read
           struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN);
                                    ^~~~
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   arch/x86/kernel/kvm.c:336:7: warning: Value stored to 'pa' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
                   u64 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
                       ^~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/x86/kernel/kvm.c:336:7: note: Value stored to 'pa' during its initialization is never read
                   u64 pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
                       ^~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   fs/xfs/xfs_ioctl32.c:456:3: warning: Value stored to 'cmd' is never read [clang-analyzer-deadcode.DeadStores]
                   cmd = _NATIVE_IOC(cmd, struct xfs_flock64);
                   ^
   fs/xfs/xfs_ioctl32.c:456:3: note: Value stored to 'cmd' is never read
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).

vim +/data +683 arch/x86/crypto/aesni-intel_glue.c

cce2ea8d90fec7 Sabrina Dubroca 2017-04-28  676  
e845520707f85c Dave Watson     2018-02-14  677  static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req,
e845520707f85c Dave Watson     2018-02-14  678  			      unsigned int assoclen, u8 *hash_subkey,
83c83e658863e4 Ard Biesheuvel  2021-01-04  679  			      u8 *iv, void *aes_ctx, u8 *auth_tag,
83c83e658863e4 Ard Biesheuvel  2021-01-04  680  			      unsigned long auth_tag_len)
e845520707f85c Dave Watson     2018-02-14  681  {
a13ed1d15b07a0 Ard Biesheuvel  2021-01-04  682  	u8 databuf[sizeof(struct gcm_context_data) + (AESNI_ALIGN - 8)] __aligned(8);
a13ed1d15b07a0 Ard Biesheuvel  2021-01-04 @683  	struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN);
e845520707f85c Dave Watson     2018-02-14  684  	unsigned long left = req->cryptlen;
e845520707f85c Dave Watson     2018-02-14  685  	struct scatter_walk assoc_sg_walk;
83c83e658863e4 Ard Biesheuvel  2021-01-04  686  	struct skcipher_walk walk;
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  687  	bool do_avx, do_avx2;
e845520707f85c Dave Watson     2018-02-14  688  	u8 *assocmem = NULL;
83c83e658863e4 Ard Biesheuvel  2021-01-04  689  	u8 *assoc;
83c83e658863e4 Ard Biesheuvel  2021-01-04  690  	int err;
377aede9f10ee2 Megha Dey       2021-01-20  691  	int hash_key_size;
377aede9f10ee2 Megha Dey       2021-01-20  692  
377aede9f10ee2 Megha Dey       2021-01-20  693  	if (static_branch_likely(&gcm_use_avx512))
377aede9f10ee2 Megha Dey       2021-01-20  694  		hash_key_size = 16 * GCM_AVX512_NUM_HASH_KEYS;
377aede9f10ee2 Megha Dey       2021-01-20  695  	else
377aede9f10ee2 Megha Dey       2021-01-20  696  		hash_key_size = 16 * GCM_BLOCK_LEN;
377aede9f10ee2 Megha Dey       2021-01-20  697  
377aede9f10ee2 Megha Dey       2021-01-20  698  	/* Allocate gcm_context_data structure on the heap. With the
377aede9f10ee2 Megha Dey       2021-01-20  699  	 * VPCLMULQDQ version of GCM needing 48 hashkeys, allocating
377aede9f10ee2 Megha Dey       2021-01-20  700  	 * this structure on the stack will inflate its size significantly.
377aede9f10ee2 Megha Dey       2021-01-20  701  	 */
377aede9f10ee2 Megha Dey       2021-01-20  702  	data = kzalloc(sizeof(*data) + hash_key_size, GFP_KERNEL);
377aede9f10ee2 Megha Dey       2021-01-20  703  	if (!data) {
377aede9f10ee2 Megha Dey       2021-01-20  704  		kfree(data);
377aede9f10ee2 Megha Dey       2021-01-20  705  		return -ENOMEM;
377aede9f10ee2 Megha Dey       2021-01-20  706  	}
e845520707f85c Dave Watson     2018-02-14  707  
e845520707f85c Dave Watson     2018-02-14  708  	if (!enc)
e845520707f85c Dave Watson     2018-02-14  709  		left -= auth_tag_len;
e845520707f85c Dave Watson     2018-02-14  710  
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  711  	do_avx = (left >= AVX_GEN2_OPTSIZE);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  712  	do_avx2 = (left >= AVX_GEN4_OPTSIZE);
603f8c3b0dbbe2 Dave Watson     2018-12-10  713  
e845520707f85c Dave Watson     2018-02-14  714  	/* Linearize assoc, if not already linear */
2694e23ffd210c Ard Biesheuvel  2021-01-04  715  	if (req->src->length >= assoclen && req->src->length) {
e845520707f85c Dave Watson     2018-02-14  716  		scatterwalk_start(&assoc_sg_walk, req->src);
e845520707f85c Dave Watson     2018-02-14  717  		assoc = scatterwalk_map(&assoc_sg_walk);
e845520707f85c Dave Watson     2018-02-14  718  	} else {
2694e23ffd210c Ard Biesheuvel  2021-01-04  719  		gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
2694e23ffd210c Ard Biesheuvel  2021-01-04  720  			      GFP_KERNEL : GFP_ATOMIC;
2694e23ffd210c Ard Biesheuvel  2021-01-04  721  
e845520707f85c Dave Watson     2018-02-14  722  		/* assoc can be any length, so must be on heap */
2694e23ffd210c Ard Biesheuvel  2021-01-04  723  		assocmem = kmalloc(assoclen, flags);
e845520707f85c Dave Watson     2018-02-14  724  		if (unlikely(!assocmem))
e845520707f85c Dave Watson     2018-02-14  725  			return -ENOMEM;
e845520707f85c Dave Watson     2018-02-14  726  		assoc = assocmem;
e845520707f85c Dave Watson     2018-02-14  727  
e845520707f85c Dave Watson     2018-02-14  728  		scatterwalk_map_and_copy(assoc, req->src, 0, assoclen, 0);
e845520707f85c Dave Watson     2018-02-14  729  	}
e845520707f85c Dave Watson     2018-02-14  730  
e845520707f85c Dave Watson     2018-02-14  731  	kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  732  
377aede9f10ee2 Megha Dey       2021-01-20  733  	if (static_branch_likely(&gcm_use_avx512) &&
377aede9f10ee2 Megha Dey       2021-01-20  734  				IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512))
377aede9f10ee2 Megha Dey       2021-01-20  735  		aesni_gcm_init_avx_512(aes_ctx, data, iv, hash_subkey, assoc,
377aede9f10ee2 Megha Dey       2021-01-20  736  				       assoclen);
377aede9f10ee2 Megha Dey       2021-01-20  737  	else if (static_branch_likely(&gcm_use_avx2) && do_avx2)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  738  		aesni_gcm_init_avx_gen4(aes_ctx, data, iv, hash_subkey, assoc,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  739  					assoclen);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  740  	else if (static_branch_likely(&gcm_use_avx) && do_avx)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  741  		aesni_gcm_init_avx_gen2(aes_ctx, data, iv, hash_subkey, assoc,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  742  					assoclen);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  743  	else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  744  		aesni_gcm_init(aes_ctx, data, iv, hash_subkey, assoc, assoclen);
e845520707f85c Dave Watson     2018-02-14  745  	kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  746  
e845520707f85c Dave Watson     2018-02-14  747  	if (!assocmem)
e845520707f85c Dave Watson     2018-02-14  748  		scatterwalk_unmap(assoc);
e845520707f85c Dave Watson     2018-02-14  749  	else
e845520707f85c Dave Watson     2018-02-14  750  		kfree(assocmem);
e845520707f85c Dave Watson     2018-02-14  751  
83c83e658863e4 Ard Biesheuvel  2021-01-04  752  	err = enc ? skcipher_walk_aead_encrypt(&walk, req, false)
83c83e658863e4 Ard Biesheuvel  2021-01-04  753  		  : skcipher_walk_aead_decrypt(&walk, req, false);
e845520707f85c Dave Watson     2018-02-14  754  
83c83e658863e4 Ard Biesheuvel  2021-01-04  755  	while (walk.nbytes > 0) {
83c83e658863e4 Ard Biesheuvel  2021-01-04  756  		kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  757  		if (static_branch_likely(&gcm_use_avx512)
377aede9f10ee2 Megha Dey       2021-01-20  758  				&& IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512)) {
377aede9f10ee2 Megha Dey       2021-01-20  759  			if (enc)
377aede9f10ee2 Megha Dey       2021-01-20  760  				aesni_gcm_enc_update_avx_512(aes_ctx, data,
377aede9f10ee2 Megha Dey       2021-01-20  761  							     walk.dst.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  762  							     walk.src.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  763  							     walk.nbytes);
377aede9f10ee2 Megha Dey       2021-01-20  764  			else
377aede9f10ee2 Megha Dey       2021-01-20  765  				aesni_gcm_dec_update_avx_512(aes_ctx, data,
377aede9f10ee2 Megha Dey       2021-01-20  766  							     walk.dst.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  767  							     walk.src.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  768  							     walk.nbytes);
377aede9f10ee2 Megha Dey       2021-01-20  769  		} else if (static_branch_likely(&gcm_use_avx2) && do_avx2) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  770  			if (enc)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  771  				aesni_gcm_enc_update_avx_gen4(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  772  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  773  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  774  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  775  			else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  776  				aesni_gcm_dec_update_avx_gen4(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  777  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  778  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  779  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  780  		} else if (static_branch_likely(&gcm_use_avx) && do_avx) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  781  			if (enc)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  782  				aesni_gcm_enc_update_avx_gen2(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  783  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  784  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  785  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  786  			else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  787  				aesni_gcm_dec_update_avx_gen2(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  788  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  789  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  790  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  791  		} else if (enc) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  792  			aesni_gcm_enc_update(aes_ctx, data, walk.dst.virt.addr,
83c83e658863e4 Ard Biesheuvel  2021-01-04  793  					     walk.src.virt.addr, walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  794  		} else {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  795  			aesni_gcm_dec_update(aes_ctx, data, walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  796  					     walk.src.virt.addr, walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  797  		}
83c83e658863e4 Ard Biesheuvel  2021-01-04  798  		kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  799  
83c83e658863e4 Ard Biesheuvel  2021-01-04  800  		err = skcipher_walk_done(&walk, 0);
e845520707f85c Dave Watson     2018-02-14  801  	}
e845520707f85c Dave Watson     2018-02-14  802  
83c83e658863e4 Ard Biesheuvel  2021-01-04  803  	if (err)
83c83e658863e4 Ard Biesheuvel  2021-01-04  804  		return err;
83c83e658863e4 Ard Biesheuvel  2021-01-04  805  
83c83e658863e4 Ard Biesheuvel  2021-01-04  806  	kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  807  	if (static_branch_likely(&gcm_use_avx512) &&
377aede9f10ee2 Megha Dey       2021-01-20  808  				IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512))
377aede9f10ee2 Megha Dey       2021-01-20  809  		aesni_gcm_finalize_avx_512(aes_ctx, data, auth_tag,
377aede9f10ee2 Megha Dey       2021-01-20  810  					   auth_tag_len);
377aede9f10ee2 Megha Dey       2021-01-20  811  	else if (static_branch_likely(&gcm_use_avx2) && do_avx2)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  812  		aesni_gcm_finalize_avx_gen4(aes_ctx, data, auth_tag,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  813  					    auth_tag_len);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  814  	else if (static_branch_likely(&gcm_use_avx) && do_avx)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  815  		aesni_gcm_finalize_avx_gen2(aes_ctx, data, auth_tag,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  816  					    auth_tag_len);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  817  	else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  818  		aesni_gcm_finalize(aes_ctx, data, auth_tag, auth_tag_len);
83c83e658863e4 Ard Biesheuvel  2021-01-04  819  	kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  820  
377aede9f10ee2 Megha Dey       2021-01-20  821  	kfree(data);
e845520707f85c Dave Watson     2018-02-14  822  	return 0;
e845520707f85c Dave Watson     2018-02-14  823  }
e845520707f85c Dave Watson     2018-02-14  824  

:::::: The code at line 683 was first introduced by commit
:::::: a13ed1d15b07a04b1f74b2df61ff7a5e47f45dd8 crypto: aesni - prevent misaligned buffers on the stack

:::::: TO: Ard Biesheuvel <ardb@kernel.org>
:::::: CC: Herbert Xu <herbert@gondor.apana.org.au>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38545 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [meghadey-crypto:crypto-avx512 5/6] arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
  2021-10-01 14:39 [meghadey-crypto:crypto-avx512 5/6] arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores] kernel test robot
@ 2021-10-10 10:13   ` kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-10-10 10:13 UTC (permalink / raw)
  To: Megha Dey; +Cc: llvm, kbuild-all, Linux Kernel Mailing List, Tomasz Kantecki

[-- Attachment #1: Type: text/plain, Size: 13200 bytes --]

tree:   https://github.com/meghadey/crypto crypto-avx512
head:   9c8c2ca77f6e2575a130bddb9767d068e1162d71
commit: 377aede9f10ee28be954473668bc6d33c6c9db75 [5/6] crypto: aesni - AVX512 version of AESNI-GCM using VPCLMULQDQ
config: x86_64-randconfig-c007-20210930 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 962e503cc8bc411f7523cc393acae8aae425b1c4)
reproduce (this is a W=1 build):
         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
         chmod +x ~/bin/make.cross
         # https://github.com/meghadey/crypto/commit/377aede9f10ee28be954473668bc6d33c6c9db75
         git remote add meghadey-crypto https://github.com/meghadey/crypto
         git fetch --no-tags meghadey-crypto crypto-avx512
         git checkout 377aede9f10ee28be954473668bc6d33c6c9db75
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)

 >> arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
            struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN);
                                     ^~~~

vim +/data +683 arch/x86/crypto/aesni-intel_glue.c

cce2ea8d90fec7 Sabrina Dubroca 2017-04-28  676
e845520707f85c Dave Watson     2018-02-14  677  static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req,
e845520707f85c Dave Watson     2018-02-14  678  			      unsigned int assoclen, u8 *hash_subkey,
83c83e658863e4 Ard Biesheuvel  2021-01-04  679  			      u8 *iv, void *aes_ctx, u8 *auth_tag,
83c83e658863e4 Ard Biesheuvel  2021-01-04  680  			      unsigned long auth_tag_len)
e845520707f85c Dave Watson     2018-02-14  681  {
a13ed1d15b07a0 Ard Biesheuvel  2021-01-04  682  	u8 databuf[sizeof(struct gcm_context_data) + (AESNI_ALIGN - 8)] __aligned(8);
a13ed1d15b07a0 Ard Biesheuvel  2021-01-04 @683  	struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN);
e845520707f85c Dave Watson     2018-02-14  684  	unsigned long left = req->cryptlen;
e845520707f85c Dave Watson     2018-02-14  685  	struct scatter_walk assoc_sg_walk;
83c83e658863e4 Ard Biesheuvel  2021-01-04  686  	struct skcipher_walk walk;
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  687  	bool do_avx, do_avx2;
e845520707f85c Dave Watson     2018-02-14  688  	u8 *assocmem = NULL;
83c83e658863e4 Ard Biesheuvel  2021-01-04  689  	u8 *assoc;
83c83e658863e4 Ard Biesheuvel  2021-01-04  690  	int err;
377aede9f10ee2 Megha Dey       2021-01-20  691  	int hash_key_size;
377aede9f10ee2 Megha Dey       2021-01-20  692
377aede9f10ee2 Megha Dey       2021-01-20  693  	if (static_branch_likely(&gcm_use_avx512))
377aede9f10ee2 Megha Dey       2021-01-20  694  		hash_key_size = 16 * GCM_AVX512_NUM_HASH_KEYS;
377aede9f10ee2 Megha Dey       2021-01-20  695  	else
377aede9f10ee2 Megha Dey       2021-01-20  696  		hash_key_size = 16 * GCM_BLOCK_LEN;
377aede9f10ee2 Megha Dey       2021-01-20  697
377aede9f10ee2 Megha Dey       2021-01-20  698  	/* Allocate gcm_context_data structure on the heap. With the
377aede9f10ee2 Megha Dey       2021-01-20  699  	 * VPCLMULQDQ version of GCM needing 48 hashkeys, allocating
377aede9f10ee2 Megha Dey       2021-01-20  700  	 * this structure on the stack will inflate its size significantly.
377aede9f10ee2 Megha Dey       2021-01-20  701  	 */
377aede9f10ee2 Megha Dey       2021-01-20  702  	data = kzalloc(sizeof(*data) + hash_key_size, GFP_KERNEL);
377aede9f10ee2 Megha Dey       2021-01-20  703  	if (!data) {
377aede9f10ee2 Megha Dey       2021-01-20  704  		kfree(data);
377aede9f10ee2 Megha Dey       2021-01-20  705  		return -ENOMEM;
377aede9f10ee2 Megha Dey       2021-01-20  706  	}
e845520707f85c Dave Watson     2018-02-14  707
e845520707f85c Dave Watson     2018-02-14  708  	if (!enc)
e845520707f85c Dave Watson     2018-02-14  709  		left -= auth_tag_len;
e845520707f85c Dave Watson     2018-02-14  710
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  711  	do_avx = (left >= AVX_GEN2_OPTSIZE);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  712  	do_avx2 = (left >= AVX_GEN4_OPTSIZE);
603f8c3b0dbbe2 Dave Watson     2018-12-10  713
e845520707f85c Dave Watson     2018-02-14  714  	/* Linearize assoc, if not already linear */
2694e23ffd210c Ard Biesheuvel  2021-01-04  715  	if (req->src->length >= assoclen && req->src->length) {
e845520707f85c Dave Watson     2018-02-14  716  		scatterwalk_start(&assoc_sg_walk, req->src);
e845520707f85c Dave Watson     2018-02-14  717  		assoc = scatterwalk_map(&assoc_sg_walk);
e845520707f85c Dave Watson     2018-02-14  718  	} else {
2694e23ffd210c Ard Biesheuvel  2021-01-04  719  		gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
2694e23ffd210c Ard Biesheuvel  2021-01-04  720  			      GFP_KERNEL : GFP_ATOMIC;
2694e23ffd210c Ard Biesheuvel  2021-01-04  721
e845520707f85c Dave Watson     2018-02-14  722  		/* assoc can be any length, so must be on heap */
2694e23ffd210c Ard Biesheuvel  2021-01-04  723  		assocmem = kmalloc(assoclen, flags);
e845520707f85c Dave Watson     2018-02-14  724  		if (unlikely(!assocmem))
e845520707f85c Dave Watson     2018-02-14  725  			return -ENOMEM;
e845520707f85c Dave Watson     2018-02-14  726  		assoc = assocmem;
e845520707f85c Dave Watson     2018-02-14  727
e845520707f85c Dave Watson     2018-02-14  728  		scatterwalk_map_and_copy(assoc, req->src, 0, assoclen, 0);
e845520707f85c Dave Watson     2018-02-14  729  	}
e845520707f85c Dave Watson     2018-02-14  730
e845520707f85c Dave Watson     2018-02-14  731  	kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  732
377aede9f10ee2 Megha Dey       2021-01-20  733  	if (static_branch_likely(&gcm_use_avx512) &&
377aede9f10ee2 Megha Dey       2021-01-20  734  				IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512))
377aede9f10ee2 Megha Dey       2021-01-20  735  		aesni_gcm_init_avx_512(aes_ctx, data, iv, hash_subkey, assoc,
377aede9f10ee2 Megha Dey       2021-01-20  736  				       assoclen);
377aede9f10ee2 Megha Dey       2021-01-20  737  	else if (static_branch_likely(&gcm_use_avx2) && do_avx2)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  738  		aesni_gcm_init_avx_gen4(aes_ctx, data, iv, hash_subkey, assoc,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  739  					assoclen);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  740  	else if (static_branch_likely(&gcm_use_avx) && do_avx)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  741  		aesni_gcm_init_avx_gen2(aes_ctx, data, iv, hash_subkey, assoc,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  742  					assoclen);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  743  	else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  744  		aesni_gcm_init(aes_ctx, data, iv, hash_subkey, assoc, assoclen);
e845520707f85c Dave Watson     2018-02-14  745  	kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  746
e845520707f85c Dave Watson     2018-02-14  747  	if (!assocmem)
e845520707f85c Dave Watson     2018-02-14  748  		scatterwalk_unmap(assoc);
e845520707f85c Dave Watson     2018-02-14  749  	else
e845520707f85c Dave Watson     2018-02-14  750  		kfree(assocmem);
e845520707f85c Dave Watson     2018-02-14  751
83c83e658863e4 Ard Biesheuvel  2021-01-04  752  	err = enc ? skcipher_walk_aead_encrypt(&walk, req, false)
83c83e658863e4 Ard Biesheuvel  2021-01-04  753  		  : skcipher_walk_aead_decrypt(&walk, req, false);
e845520707f85c Dave Watson     2018-02-14  754
83c83e658863e4 Ard Biesheuvel  2021-01-04  755  	while (walk.nbytes > 0) {
83c83e658863e4 Ard Biesheuvel  2021-01-04  756  		kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  757  		if (static_branch_likely(&gcm_use_avx512)
377aede9f10ee2 Megha Dey       2021-01-20  758  				&& IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512)) {
377aede9f10ee2 Megha Dey       2021-01-20  759  			if (enc)
377aede9f10ee2 Megha Dey       2021-01-20  760  				aesni_gcm_enc_update_avx_512(aes_ctx, data,
377aede9f10ee2 Megha Dey       2021-01-20  761  							     walk.dst.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  762  							     walk.src.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  763  							     walk.nbytes);
377aede9f10ee2 Megha Dey       2021-01-20  764  			else
377aede9f10ee2 Megha Dey       2021-01-20  765  				aesni_gcm_dec_update_avx_512(aes_ctx, data,
377aede9f10ee2 Megha Dey       2021-01-20  766  							     walk.dst.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  767  							     walk.src.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  768  							     walk.nbytes);
377aede9f10ee2 Megha Dey       2021-01-20  769  		} else if (static_branch_likely(&gcm_use_avx2) && do_avx2) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  770  			if (enc)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  771  				aesni_gcm_enc_update_avx_gen4(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  772  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  773  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  774  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  775  			else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  776  				aesni_gcm_dec_update_avx_gen4(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  777  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  778  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  779  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  780  		} else if (static_branch_likely(&gcm_use_avx) && do_avx) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  781  			if (enc)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  782  				aesni_gcm_enc_update_avx_gen2(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  783  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  784  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  785  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  786  			else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  787  				aesni_gcm_dec_update_avx_gen2(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  788  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  789  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  790  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  791  		} else if (enc) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  792  			aesni_gcm_enc_update(aes_ctx, data, walk.dst.virt.addr,
83c83e658863e4 Ard Biesheuvel  2021-01-04  793  					     walk.src.virt.addr, walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  794  		} else {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  795  			aesni_gcm_dec_update(aes_ctx, data, walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  796  					     walk.src.virt.addr, walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  797  		}
83c83e658863e4 Ard Biesheuvel  2021-01-04  798  		kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  799
83c83e658863e4 Ard Biesheuvel  2021-01-04  800  		err = skcipher_walk_done(&walk, 0);
e845520707f85c Dave Watson     2018-02-14  801  	}
e845520707f85c Dave Watson     2018-02-14  802
83c83e658863e4 Ard Biesheuvel  2021-01-04  803  	if (err)
83c83e658863e4 Ard Biesheuvel  2021-01-04  804  		return err;
83c83e658863e4 Ard Biesheuvel  2021-01-04  805
83c83e658863e4 Ard Biesheuvel  2021-01-04  806  	kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  807  	if (static_branch_likely(&gcm_use_avx512) &&
377aede9f10ee2 Megha Dey       2021-01-20  808  				IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512))
377aede9f10ee2 Megha Dey       2021-01-20  809  		aesni_gcm_finalize_avx_512(aes_ctx, data, auth_tag,
377aede9f10ee2 Megha Dey       2021-01-20  810  					   auth_tag_len);
377aede9f10ee2 Megha Dey       2021-01-20  811  	else if (static_branch_likely(&gcm_use_avx2) && do_avx2)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  812  		aesni_gcm_finalize_avx_gen4(aes_ctx, data, auth_tag,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  813  					    auth_tag_len);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  814  	else if (static_branch_likely(&gcm_use_avx) && do_avx)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  815  		aesni_gcm_finalize_avx_gen2(aes_ctx, data, auth_tag,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  816  					    auth_tag_len);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  817  	else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  818  		aesni_gcm_finalize(aes_ctx, data, auth_tag, auth_tag_len);
83c83e658863e4 Ard Biesheuvel  2021-01-04  819  	kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  820
377aede9f10ee2 Megha Dey       2021-01-20  821  	kfree(data);
e845520707f85c Dave Watson     2018-02-14  822  	return 0;
e845520707f85c Dave Watson     2018-02-14  823  }
e845520707f85c Dave Watson     2018-02-14  824

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38545 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [meghadey-crypto:crypto-avx512 5/6] arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
@ 2021-10-10 10:13   ` kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-10-10 10:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 13383 bytes --]

tree:   https://github.com/meghadey/crypto crypto-avx512
head:   9c8c2ca77f6e2575a130bddb9767d068e1162d71
commit: 377aede9f10ee28be954473668bc6d33c6c9db75 [5/6] crypto: aesni - AVX512 version of AESNI-GCM using VPCLMULQDQ
config: x86_64-randconfig-c007-20210930 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 962e503cc8bc411f7523cc393acae8aae425b1c4)
reproduce (this is a W=1 build):
         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
         chmod +x ~/bin/make.cross
         # https://github.com/meghadey/crypto/commit/377aede9f10ee28be954473668bc6d33c6c9db75
         git remote add meghadey-crypto https://github.com/meghadey/crypto
         git fetch --no-tags meghadey-crypto crypto-avx512
         git checkout 377aede9f10ee28be954473668bc6d33c6c9db75
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)

 >> arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
            struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN);
                                     ^~~~

vim +/data +683 arch/x86/crypto/aesni-intel_glue.c

cce2ea8d90fec7 Sabrina Dubroca 2017-04-28  676
e845520707f85c Dave Watson     2018-02-14  677  static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req,
e845520707f85c Dave Watson     2018-02-14  678  			      unsigned int assoclen, u8 *hash_subkey,
83c83e658863e4 Ard Biesheuvel  2021-01-04  679  			      u8 *iv, void *aes_ctx, u8 *auth_tag,
83c83e658863e4 Ard Biesheuvel  2021-01-04  680  			      unsigned long auth_tag_len)
e845520707f85c Dave Watson     2018-02-14  681  {
a13ed1d15b07a0 Ard Biesheuvel  2021-01-04  682  	u8 databuf[sizeof(struct gcm_context_data) + (AESNI_ALIGN - 8)] __aligned(8);
a13ed1d15b07a0 Ard Biesheuvel  2021-01-04 @683  	struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN);
e845520707f85c Dave Watson     2018-02-14  684  	unsigned long left = req->cryptlen;
e845520707f85c Dave Watson     2018-02-14  685  	struct scatter_walk assoc_sg_walk;
83c83e658863e4 Ard Biesheuvel  2021-01-04  686  	struct skcipher_walk walk;
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  687  	bool do_avx, do_avx2;
e845520707f85c Dave Watson     2018-02-14  688  	u8 *assocmem = NULL;
83c83e658863e4 Ard Biesheuvel  2021-01-04  689  	u8 *assoc;
83c83e658863e4 Ard Biesheuvel  2021-01-04  690  	int err;
377aede9f10ee2 Megha Dey       2021-01-20  691  	int hash_key_size;
377aede9f10ee2 Megha Dey       2021-01-20  692
377aede9f10ee2 Megha Dey       2021-01-20  693  	if (static_branch_likely(&gcm_use_avx512))
377aede9f10ee2 Megha Dey       2021-01-20  694  		hash_key_size = 16 * GCM_AVX512_NUM_HASH_KEYS;
377aede9f10ee2 Megha Dey       2021-01-20  695  	else
377aede9f10ee2 Megha Dey       2021-01-20  696  		hash_key_size = 16 * GCM_BLOCK_LEN;
377aede9f10ee2 Megha Dey       2021-01-20  697
377aede9f10ee2 Megha Dey       2021-01-20  698  	/* Allocate gcm_context_data structure on the heap. With the
377aede9f10ee2 Megha Dey       2021-01-20  699  	 * VPCLMULQDQ version of GCM needing 48 hashkeys, allocating
377aede9f10ee2 Megha Dey       2021-01-20  700  	 * this structure on the stack will inflate its size significantly.
377aede9f10ee2 Megha Dey       2021-01-20  701  	 */
377aede9f10ee2 Megha Dey       2021-01-20  702  	data = kzalloc(sizeof(*data) + hash_key_size, GFP_KERNEL);
377aede9f10ee2 Megha Dey       2021-01-20  703  	if (!data) {
377aede9f10ee2 Megha Dey       2021-01-20  704  		kfree(data);
377aede9f10ee2 Megha Dey       2021-01-20  705  		return -ENOMEM;
377aede9f10ee2 Megha Dey       2021-01-20  706  	}
e845520707f85c Dave Watson     2018-02-14  707
e845520707f85c Dave Watson     2018-02-14  708  	if (!enc)
e845520707f85c Dave Watson     2018-02-14  709  		left -= auth_tag_len;
e845520707f85c Dave Watson     2018-02-14  710
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  711  	do_avx = (left >= AVX_GEN2_OPTSIZE);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  712  	do_avx2 = (left >= AVX_GEN4_OPTSIZE);
603f8c3b0dbbe2 Dave Watson     2018-12-10  713
e845520707f85c Dave Watson     2018-02-14  714  	/* Linearize assoc, if not already linear */
2694e23ffd210c Ard Biesheuvel  2021-01-04  715  	if (req->src->length >= assoclen && req->src->length) {
e845520707f85c Dave Watson     2018-02-14  716  		scatterwalk_start(&assoc_sg_walk, req->src);
e845520707f85c Dave Watson     2018-02-14  717  		assoc = scatterwalk_map(&assoc_sg_walk);
e845520707f85c Dave Watson     2018-02-14  718  	} else {
2694e23ffd210c Ard Biesheuvel  2021-01-04  719  		gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
2694e23ffd210c Ard Biesheuvel  2021-01-04  720  			      GFP_KERNEL : GFP_ATOMIC;
2694e23ffd210c Ard Biesheuvel  2021-01-04  721
e845520707f85c Dave Watson     2018-02-14  722  		/* assoc can be any length, so must be on heap */
2694e23ffd210c Ard Biesheuvel  2021-01-04  723  		assocmem = kmalloc(assoclen, flags);
e845520707f85c Dave Watson     2018-02-14  724  		if (unlikely(!assocmem))
e845520707f85c Dave Watson     2018-02-14  725  			return -ENOMEM;
e845520707f85c Dave Watson     2018-02-14  726  		assoc = assocmem;
e845520707f85c Dave Watson     2018-02-14  727
e845520707f85c Dave Watson     2018-02-14  728  		scatterwalk_map_and_copy(assoc, req->src, 0, assoclen, 0);
e845520707f85c Dave Watson     2018-02-14  729  	}
e845520707f85c Dave Watson     2018-02-14  730
e845520707f85c Dave Watson     2018-02-14  731  	kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  732
377aede9f10ee2 Megha Dey       2021-01-20  733  	if (static_branch_likely(&gcm_use_avx512) &&
377aede9f10ee2 Megha Dey       2021-01-20  734  				IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512))
377aede9f10ee2 Megha Dey       2021-01-20  735  		aesni_gcm_init_avx_512(aes_ctx, data, iv, hash_subkey, assoc,
377aede9f10ee2 Megha Dey       2021-01-20  736  				       assoclen);
377aede9f10ee2 Megha Dey       2021-01-20  737  	else if (static_branch_likely(&gcm_use_avx2) && do_avx2)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  738  		aesni_gcm_init_avx_gen4(aes_ctx, data, iv, hash_subkey, assoc,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  739  					assoclen);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  740  	else if (static_branch_likely(&gcm_use_avx) && do_avx)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  741  		aesni_gcm_init_avx_gen2(aes_ctx, data, iv, hash_subkey, assoc,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  742  					assoclen);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  743  	else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  744  		aesni_gcm_init(aes_ctx, data, iv, hash_subkey, assoc, assoclen);
e845520707f85c Dave Watson     2018-02-14  745  	kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  746
e845520707f85c Dave Watson     2018-02-14  747  	if (!assocmem)
e845520707f85c Dave Watson     2018-02-14  748  		scatterwalk_unmap(assoc);
e845520707f85c Dave Watson     2018-02-14  749  	else
e845520707f85c Dave Watson     2018-02-14  750  		kfree(assocmem);
e845520707f85c Dave Watson     2018-02-14  751
83c83e658863e4 Ard Biesheuvel  2021-01-04  752  	err = enc ? skcipher_walk_aead_encrypt(&walk, req, false)
83c83e658863e4 Ard Biesheuvel  2021-01-04  753  		  : skcipher_walk_aead_decrypt(&walk, req, false);
e845520707f85c Dave Watson     2018-02-14  754
83c83e658863e4 Ard Biesheuvel  2021-01-04  755  	while (walk.nbytes > 0) {
83c83e658863e4 Ard Biesheuvel  2021-01-04  756  		kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  757  		if (static_branch_likely(&gcm_use_avx512)
377aede9f10ee2 Megha Dey       2021-01-20  758  				&& IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512)) {
377aede9f10ee2 Megha Dey       2021-01-20  759  			if (enc)
377aede9f10ee2 Megha Dey       2021-01-20  760  				aesni_gcm_enc_update_avx_512(aes_ctx, data,
377aede9f10ee2 Megha Dey       2021-01-20  761  							     walk.dst.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  762  							     walk.src.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  763  							     walk.nbytes);
377aede9f10ee2 Megha Dey       2021-01-20  764  			else
377aede9f10ee2 Megha Dey       2021-01-20  765  				aesni_gcm_dec_update_avx_512(aes_ctx, data,
377aede9f10ee2 Megha Dey       2021-01-20  766  							     walk.dst.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  767  							     walk.src.virt.addr,
377aede9f10ee2 Megha Dey       2021-01-20  768  							     walk.nbytes);
377aede9f10ee2 Megha Dey       2021-01-20  769  		} else if (static_branch_likely(&gcm_use_avx2) && do_avx2) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  770  			if (enc)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  771  				aesni_gcm_enc_update_avx_gen4(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  772  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  773  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  774  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  775  			else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  776  				aesni_gcm_dec_update_avx_gen4(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  777  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  778  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  779  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  780  		} else if (static_branch_likely(&gcm_use_avx) && do_avx) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  781  			if (enc)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  782  				aesni_gcm_enc_update_avx_gen2(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  783  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  784  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  785  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  786  			else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  787  				aesni_gcm_dec_update_avx_gen2(aes_ctx, data,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  788  							      walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  789  							      walk.src.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  790  							      walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  791  		} else if (enc) {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  792  			aesni_gcm_enc_update(aes_ctx, data, walk.dst.virt.addr,
83c83e658863e4 Ard Biesheuvel  2021-01-04  793  					     walk.src.virt.addr, walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  794  		} else {
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  795  			aesni_gcm_dec_update(aes_ctx, data, walk.dst.virt.addr,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  796  					     walk.src.virt.addr, walk.nbytes);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  797  		}
83c83e658863e4 Ard Biesheuvel  2021-01-04  798  		kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  799
83c83e658863e4 Ard Biesheuvel  2021-01-04  800  		err = skcipher_walk_done(&walk, 0);
e845520707f85c Dave Watson     2018-02-14  801  	}
e845520707f85c Dave Watson     2018-02-14  802
83c83e658863e4 Ard Biesheuvel  2021-01-04  803  	if (err)
83c83e658863e4 Ard Biesheuvel  2021-01-04  804  		return err;
83c83e658863e4 Ard Biesheuvel  2021-01-04  805
83c83e658863e4 Ard Biesheuvel  2021-01-04  806  	kernel_fpu_begin();
377aede9f10ee2 Megha Dey       2021-01-20  807  	if (static_branch_likely(&gcm_use_avx512) &&
377aede9f10ee2 Megha Dey       2021-01-20  808  				IS_ENABLED(CONFIG_CRYPTO_AES_GCM_AVX512))
377aede9f10ee2 Megha Dey       2021-01-20  809  		aesni_gcm_finalize_avx_512(aes_ctx, data, auth_tag,
377aede9f10ee2 Megha Dey       2021-01-20  810  					   auth_tag_len);
377aede9f10ee2 Megha Dey       2021-01-20  811  	else if (static_branch_likely(&gcm_use_avx2) && do_avx2)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  812  		aesni_gcm_finalize_avx_gen4(aes_ctx, data, auth_tag,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  813  					    auth_tag_len);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  814  	else if (static_branch_likely(&gcm_use_avx) && do_avx)
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  815  		aesni_gcm_finalize_avx_gen2(aes_ctx, data, auth_tag,
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  816  					    auth_tag_len);
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  817  	else
d6cbf4eaa46794 Ard Biesheuvel  2021-01-04  818  		aesni_gcm_finalize(aes_ctx, data, auth_tag, auth_tag_len);
83c83e658863e4 Ard Biesheuvel  2021-01-04  819  	kernel_fpu_end();
e845520707f85c Dave Watson     2018-02-14  820
377aede9f10ee2 Megha Dey       2021-01-20  821  	kfree(data);
e845520707f85c Dave Watson     2018-02-14  822  	return 0;
e845520707f85c Dave Watson     2018-02-14  823  }
e845520707f85c Dave Watson     2018-02-14  824

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38545 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-10 10:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 14:39 [meghadey-crypto:crypto-avx512 5/6] arch/x86/crypto/aesni-intel_glue.c:683:27: warning: Value stored to 'data' during its initialization is never read [clang-analyzer-deadcode.DeadStores] kernel test robot
2021-10-10 10:13 ` kernel test robot
2021-10-10 10:13   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.