Re: [PATCH v5 7/7] Enable Driver compilation in crypto Kconfig and Makefile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Pavitrakumar,

kernel test robot noticed the following build warnings:

url:    https://github.com/intel-lab-lkp/linux/commits/Pavitrakumar-M/Add-SPAcc-Skcipher-support/20240625-184208
base:   1dcf865d3bf5bff45e93cb2410911b3428dacb78
patch link:    https://lore.kernel.org/r/20240621082053.638952-8-pavitrakumarm%40vayavyalabs.com
patch subject: [PATCH v5 7/7] Enable Driver compilation in crypto Kconfig and Makefile
config: x86_64-randconfig-161-20240626 (https://download.01.org/0day-ci/archive/20240626/202406260926.bfyJ84yf-lkp@xxxxxxxxx/config)
compiler: gcc-10 (Ubuntu 10.5.0-1ubuntu1) 10.5.0

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/202406260926.bfyJ84yf-lkp@xxxxxxxxx/

New smatch warnings:
drivers/crypto/dwc-spacc/spacc_core.c:1029 fixup_sg() error: we previously assumed 'sg' could be null (see line 1008)

Old smatch warnings:
drivers/crypto/dwc-spacc/spacc_core.c:1417 spacc_isenabled() error: buffer overflow 'spacc->config.modes' 81 <= 81
drivers/crypto/dwc-spacc/spacc_core.c:1422 spacc_isenabled() error: buffer overflow 'spacc->config.modes' 81 <= 81
drivers/crypto/dwc-spacc/spacc_core.c:2018 spacc_open() warn: inconsistent indenting

vim +/sg +1029 drivers/crypto/dwc-spacc/spacc_core.c

8e3d92f71646e6 Pavitrakumar M 2024-06-21  1003  static int fixup_sg(struct scatterlist *sg, int nbytes)
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1004  {
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1005  	int sg_nents = 0;
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1006  
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1007  	while (nbytes > 0) {
8e3d92f71646e6 Pavitrakumar M 2024-06-21 @1008  		if (sg && sg->length) {

Can we really pass a NULL sg?

8e3d92f71646e6 Pavitrakumar M 2024-06-21  1009  			++sg_nents;
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1010  
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1011  			if (sg->length > nbytes)
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1012  				return sg_nents;
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1013  
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1014  			nbytes -= sg->length;
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1015  
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1016  			sg = sg_next(sg);
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1017  			if (!sg)
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1018  				break;
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1019  			/* WARNING: sg->length may be > nbytes */
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1020  		} else {
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1021  			/*
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1022  			 * The Linux crypto system uses its own SG chaining
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1023  			 * method which is slightly incompatible with the
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1024  			 * generic SG chaining. In particular, dma_map_sg does
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1025  			 * not support this method. Turn them into proper
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1026  			 * chained SGs here (which dma_map_sg does
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1027  			 * support) as a workaround.
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1028  			 */
8e3d92f71646e6 Pavitrakumar M 2024-06-21 @1029  			spacc_sg_chain(sg, 1, sg_chain_ptr(sg));
                                                                                       ^^^                 ^^
Because if so, we're toast.

8e3d92f71646e6 Pavitrakumar M 2024-06-21  1030  			sg = sg_chain_ptr(sg);
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1031  			if (!sg)
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1032  				break;
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1033  		}
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1034  	}
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1035  
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1036  	return sg_nents;
8e3d92f71646e6 Pavitrakumar M 2024-06-21  1037  }

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





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux