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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <129493f0-211f-408f-8435-2e6fead3f07b@moroto.mountain>
Date: Mon, 27 May 2024 10:48:15 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: oe-kbuild@...ts.linux.dev, David Gstir <david@...ma-star.at>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
	linux-kernel@...r.kernel.org, Jarkko Sakkinen <jarkko@...nel.org>,
	Richard Weinberger <richard@....at>,
	David Oberhollenzer <david.oberhollenzer@...ma-star.at>
Subject: drivers/crypto/mxs-dcp.c:292 mxs_dcp_run_aes() error: uninitialized
 symbol 'key_phys'.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   c13320499ba0efd93174ef6462ae8a7a2933f6e7
commit: 3d16af0b4cfac4b2c3b238e2ec37b38c2f316978 crypto: mxs-dcp: Add support for hardware-bound keys
config: arm-randconfig-r071-20240524 (https://download.01.org/0day-ci/archive/20240527/202405270146.Y9tPoil8-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 7aa382fd7257d9bd4f7fc50bb7078a3c26a1628c)

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@...el.com>
| Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
| Closes: https://lore.kernel.org/r/202405270146.Y9tPoil8-lkp@intel.com/

smatch warnings:
drivers/crypto/mxs-dcp.c:292 mxs_dcp_run_aes() error: uninitialized symbol 'key_phys'.

vim +/key_phys +292 drivers/crypto/mxs-dcp.c

2021abaa00da64a Marek Vasut    2014-01-14  225  static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
9acb3247e0e1d94 Ard Biesheuvel 2019-11-09  226  			   struct skcipher_request *req, int init)
15b59e7c3733f90 Marek Vasut    2013-12-10  227  {
df6313d707e575a Sean Anderson  2021-07-01  228  	dma_addr_t key_phys, src_phys, dst_phys;
15b59e7c3733f90 Marek Vasut    2013-12-10  229  	struct dcp *sdcp = global_sdcp;
15b59e7c3733f90 Marek Vasut    2013-12-10  230  	struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
9acb3247e0e1d94 Ard Biesheuvel 2019-11-09  231  	struct dcp_aes_req_ctx *rctx = skcipher_request_ctx(req);
3d16af0b4cfac4b David Gstir    2024-04-03  232  	bool key_referenced = actx->key_referenced;
15b59e7c3733f90 Marek Vasut    2013-12-10  233  	int ret;
15b59e7c3733f90 Marek Vasut    2013-12-10  234  
3d16af0b4cfac4b David Gstir    2024-04-03  235  	if (!key_referenced) {
df6313d707e575a Sean Anderson  2021-07-01  236  		key_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_key,
df6313d707e575a Sean Anderson  2021-07-01  237  					  2 * AES_KEYSIZE_128, DMA_TO_DEVICE);
df6313d707e575a Sean Anderson  2021-07-01  238  		ret = dma_mapping_error(sdcp->dev, key_phys);
df6313d707e575a Sean Anderson  2021-07-01  239  		if (ret)
df6313d707e575a Sean Anderson  2021-07-01  240  			return ret;
3d16af0b4cfac4b David Gstir    2024-04-03  241  	}

key_phys not initialized on else path.

df6313d707e575a Sean Anderson  2021-07-01  242  
df6313d707e575a Sean Anderson  2021-07-01  243  	src_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_in_buf,
15b59e7c3733f90 Marek Vasut    2013-12-10  244  				  DCP_BUF_SZ, DMA_TO_DEVICE);
df6313d707e575a Sean Anderson  2021-07-01  245  	ret = dma_mapping_error(sdcp->dev, src_phys);
df6313d707e575a Sean Anderson  2021-07-01  246  	if (ret)
df6313d707e575a Sean Anderson  2021-07-01  247  		goto err_src;
df6313d707e575a Sean Anderson  2021-07-01  248  
df6313d707e575a Sean Anderson  2021-07-01  249  	dst_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_out_buf,
15b59e7c3733f90 Marek Vasut    2013-12-10  250  				  DCP_BUF_SZ, DMA_FROM_DEVICE);
df6313d707e575a Sean Anderson  2021-07-01  251  	ret = dma_mapping_error(sdcp->dev, dst_phys);
df6313d707e575a Sean Anderson  2021-07-01  252  	if (ret)
df6313d707e575a Sean Anderson  2021-07-01  253  		goto err_dst;
15b59e7c3733f90 Marek Vasut    2013-12-10  254  
fadd7a6e616b89c Radu Solea     2018-10-02  255  	if (actx->fill % AES_BLOCK_SIZE) {
fadd7a6e616b89c Radu Solea     2018-10-02  256  		dev_err(sdcp->dev, "Invalid block size!\n");
fadd7a6e616b89c Radu Solea     2018-10-02  257  		ret = -EINVAL;
fadd7a6e616b89c Radu Solea     2018-10-02  258  		goto aes_done_run;
fadd7a6e616b89c Radu Solea     2018-10-02  259  	}
fadd7a6e616b89c Radu Solea     2018-10-02  260  
15b59e7c3733f90 Marek Vasut    2013-12-10  261  	/* Fill in the DMA descriptor. */
15b59e7c3733f90 Marek Vasut    2013-12-10  262  	desc->control0 = MXS_DCP_CONTROL0_DECR_SEMAPHORE |
15b59e7c3733f90 Marek Vasut    2013-12-10  263  		    MXS_DCP_CONTROL0_INTERRUPT |
15b59e7c3733f90 Marek Vasut    2013-12-10  264  		    MXS_DCP_CONTROL0_ENABLE_CIPHER;
15b59e7c3733f90 Marek Vasut    2013-12-10  265  
3d16af0b4cfac4b David Gstir    2024-04-03  266  	if (key_referenced)
3d16af0b4cfac4b David Gstir    2024-04-03  267  		/* Set OTP key bit to select the key via KEY_SELECT. */
3d16af0b4cfac4b David Gstir    2024-04-03  268  		desc->control0 |= MXS_DCP_CONTROL0_OTP_KEY;
3d16af0b4cfac4b David Gstir    2024-04-03  269  	else
15b59e7c3733f90 Marek Vasut    2013-12-10  270  		/* Payload contains the key. */
15b59e7c3733f90 Marek Vasut    2013-12-10  271  		desc->control0 |= MXS_DCP_CONTROL0_PAYLOAD_KEY;
15b59e7c3733f90 Marek Vasut    2013-12-10  272  
2021abaa00da64a Marek Vasut    2014-01-14  273  	if (rctx->enc)
15b59e7c3733f90 Marek Vasut    2013-12-10  274  		desc->control0 |= MXS_DCP_CONTROL0_CIPHER_ENCRYPT;
15b59e7c3733f90 Marek Vasut    2013-12-10  275  	if (init)
15b59e7c3733f90 Marek Vasut    2013-12-10  276  		desc->control0 |= MXS_DCP_CONTROL0_CIPHER_INIT;
15b59e7c3733f90 Marek Vasut    2013-12-10  277  
15b59e7c3733f90 Marek Vasut    2013-12-10  278  	desc->control1 = MXS_DCP_CONTROL1_CIPHER_SELECT_AES128;
15b59e7c3733f90 Marek Vasut    2013-12-10  279  
2021abaa00da64a Marek Vasut    2014-01-14  280  	if (rctx->ecb)
15b59e7c3733f90 Marek Vasut    2013-12-10  281  		desc->control1 |= MXS_DCP_CONTROL1_CIPHER_MODE_ECB;
15b59e7c3733f90 Marek Vasut    2013-12-10  282  	else
15b59e7c3733f90 Marek Vasut    2013-12-10  283  		desc->control1 |= MXS_DCP_CONTROL1_CIPHER_MODE_CBC;
15b59e7c3733f90 Marek Vasut    2013-12-10  284  
3d16af0b4cfac4b David Gstir    2024-04-03  285  	if (key_referenced)
3d16af0b4cfac4b David Gstir    2024-04-03  286  		desc->control1 |= sdcp->coh->aes_key[0] << MXS_DCP_CONTROL1_KEY_SELECT_SHIFT;
3d16af0b4cfac4b David Gstir    2024-04-03  287  
15b59e7c3733f90 Marek Vasut    2013-12-10  288  	desc->next_cmd_addr = 0;
15b59e7c3733f90 Marek Vasut    2013-12-10  289  	desc->source = src_phys;
15b59e7c3733f90 Marek Vasut    2013-12-10  290  	desc->destination = dst_phys;
15b59e7c3733f90 Marek Vasut    2013-12-10  291  	desc->size = actx->fill;
15b59e7c3733f90 Marek Vasut    2013-12-10 @292  	desc->payload = key_phys;
                                                                        ^^^^^^^^
Uninitialized.

15b59e7c3733f90 Marek Vasut    2013-12-10  293  	desc->status = 0;
15b59e7c3733f90 Marek Vasut    2013-12-10  294  
15b59e7c3733f90 Marek Vasut    2013-12-10  295  	ret = mxs_dcp_start_dma(actx);
15b59e7c3733f90 Marek Vasut    2013-12-10  296  
fadd7a6e616b89c Radu Solea     2018-10-02  297  aes_done_run:
df6313d707e575a Sean Anderson  2021-07-01  298  	dma_unmap_single(sdcp->dev, dst_phys, DCP_BUF_SZ, DMA_FROM_DEVICE);
df6313d707e575a Sean Anderson  2021-07-01  299  err_dst:
df6313d707e575a Sean Anderson  2021-07-01  300  	dma_unmap_single(sdcp->dev, src_phys, DCP_BUF_SZ, DMA_TO_DEVICE);
df6313d707e575a Sean Anderson  2021-07-01  301  err_src:
3d16af0b4cfac4b David Gstir    2024-04-03  302  	if (!key_referenced)
15b59e7c3733f90 Marek Vasut    2013-12-10  303  		dma_unmap_single(sdcp->dev, key_phys, 2 * AES_KEYSIZE_128,
15b59e7c3733f90 Marek Vasut    2013-12-10  304  				 DMA_TO_DEVICE);
15b59e7c3733f90 Marek Vasut    2013-12-10  305  	return ret;
15b59e7c3733f90 Marek Vasut    2013-12-10  306  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ