lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 27 Oct 2022 07:13:45 +0800
From:   kernel test robot <lkp@...el.com>
To:     'Guanjun' <guanjun@...ux.alibaba.com>, herbert@...dor.apana.org.au,
        elliott@....com
Cc:     oe-kbuild-all@...ts.linux.dev, zelin.deng@...ux.alibaba.com,
        artie.ding@...ux.alibaba.com, guanjun@...ux.alibaba.com,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
        xuchun.shang@...ux.alibaba.com
Subject: Re: [PATCH v3 6/9] crypto/ycc: Add aead algorithm support

Hi 'Guanjun',

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master linus/master v6.1-rc2 next-20221026]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Guanjun/Drivers-for-Alibaba-YCC-Yitian-Cryptography-Complex-cryptographic-accelerator/20221025-180005
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/1666691616-69983-7-git-send-email-guanjun%40linux.alibaba.com
patch subject: [PATCH v3 6/9] crypto/ycc: Add aead algorithm support
config: csky-randconfig-s033-20221026
compiler: csky-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/04c66693149fbf08645a6f86656cf27c07ab1cd0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Guanjun/Drivers-for-Alibaba-YCC-Yitian-Cryptography-Complex-cryptographic-accelerator/20221025-180005
        git checkout 04c66693149fbf08645a6f86656cf27c07ab1cd0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash drivers/crypto/ycc/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

sparse warnings: (new ones prefixed by >>)
>> drivers/crypto/ycc/ycc_aead.c:440:38: sparse: sparse: non size-preserving pointer to integer cast

vim +440 drivers/crypto/ycc/ycc_aead.c

   368	
   369	static int ycc_aead_submit_desc(struct aead_request *aead_req, u8 cmd)
   370	{
   371		struct crypto_aead *tfm = crypto_aead_reqtfm(aead_req);
   372		struct ycc_crypto_ctx *ctx = crypto_aead_ctx(tfm);
   373		struct ycc_crypto_req *req = aead_request_ctx(aead_req);
   374		struct ycc_flags *aflags;
   375		int taglen = crypto_aead_authsize(tfm);
   376		u16 new_aad_len;
   377		u32 new_cryptlen;
   378		struct crypto_aes_ctx aes_ctx;
   379		u8 tag[16];
   380		u8 ziv[16] = {0};
   381		__be32 counter = cpu_to_be32(1);
   382		int ret = 0;
   383	
   384		/*
   385		 * YCC hw does not support gcm zero length plaintext. According to spec
   386		 * if cryptlen is 0, just do aes_encrypt against IV
   387		 */
   388		if (aead_req->cryptlen == 0 && cmd == YCC_CMD_GCM_ENC) {
   389			ret = aes_expandkey(&aes_ctx, ctx->cipher_key, ctx->keysize);
   390			if (ret)
   391				return ret;
   392			memcpy(ziv, aead_req->iv, 12);
   393			memcpy(ziv + 12, &counter, 4);
   394			aes_encrypt(&aes_ctx, tag, ziv);
   395			sg_copy_from_buffer(aead_req->dst,
   396					    sg_nents_for_len(aead_req->dst, taglen),
   397					    tag, taglen);
   398			return 0;
   399		}
   400	
   401		if (aead_req->cryptlen == taglen && cmd == YCC_CMD_GCM_DEC) {
   402			ret = aes_expandkey(&aes_ctx, ctx->cipher_key, ctx->keysize);
   403			if (ret)
   404				return ret;
   405			/* Skip aad */
   406			sg_copy_buffer(aead_req->src,
   407				       sg_nents_for_len(aead_req->src, taglen),
   408				       tag, taglen, aead_req->assoclen, 1);
   409			aes_decrypt(&aes_ctx, ziv, tag);
   410			sg_copy_from_buffer(aead_req->dst,
   411					    sg_nents_for_len(aead_req->dst, taglen),
   412					    ziv, taglen);
   413			return 0;
   414		}
   415	
   416		memset(req, 0, sizeof(*req));
   417		req->ctx = ctx;
   418		req->aead_req = aead_req;
   419	
   420		ret = ycc_aead_fill_key(req);
   421		if (ret)
   422			return ret;
   423	
   424		req->src_vaddr = ycc_aead_format_data(req, &new_aad_len, &new_cryptlen, cmd);
   425		if (!req->src_vaddr)
   426			goto free_key;
   427	
   428		ret = ycc_aead_sg_map(req);
   429		if (ret)
   430			goto unformat;
   431	
   432		ret = -ENOMEM;
   433		aflags = kzalloc(sizeof(struct ycc_flags), GFP_ATOMIC);
   434		if (!aflags)
   435			goto sg_unmap;
   436	
   437		memset(&req->desc.cmd, 0, sizeof(union ycc_real_cmd));
   438		aflags->ptr = (void *)req;
   439		aflags->ycc_done_callback = ycc_aead_callback;
 > 440		req->desc.private_ptr = (u64)aflags;
   441		req->desc.cmd.aead_cmd.cmd_id = cmd;
   442		req->desc.cmd.aead_cmd.mode = ctx->mode;
   443		req->desc.cmd.aead_cmd.sptr = req->src_paddr;
   444		req->desc.cmd.aead_cmd.dptr = req->dst_paddr;
   445		if (cmd == YCC_CMD_GCM_DEC || cmd == YCC_CMD_CCM_DEC)
   446			new_cryptlen = aead_req->cryptlen - taglen;
   447		req->desc.cmd.aead_cmd.dlen = new_cryptlen;
   448		req->desc.cmd.aead_cmd.keyptr = req->key_paddr;
   449		req->desc.cmd.aead_cmd.aadlen = new_aad_len;
   450		req->desc.cmd.aead_cmd.taglen = taglen;
   451	
   452		/* 4. submit desc to cmd queue */
   453		ret = ycc_enqueue(ctx->ring, &req->desc);
   454		if (!ret)
   455			return -EINPROGRESS;
   456	
   457		pr_err("Failed to submit desc to ring\n");
   458		kfree(aflags);
   459	
   460	sg_unmap:
   461		ycc_aead_sg_unmap(req);
   462	unformat:
   463		ycc_aead_unformat_data(req);
   464	free_key:
   465		memset(req->key_vaddr, 0, 64);
   466		dma_free_coherent(YCC_DEV(ctx), 64, req->key_vaddr, req->key_paddr);
   467		req->key_vaddr = NULL;
   468		return ret;
   469	}
   470	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (145589 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ