Re: [PATCH v33 01/12] Linux Random Number Generator

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

 



Hi "Stephan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on cryptodev/master crypto/master v5.9-rc1 next-20200821]
[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]

url:    https://github.com/0day-ci/linux/commits/Stephan-M-ller/dev-random-a-new-approach-with-full-SP800-90B-compliance/20200821-140523
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git d162219c655c8cf8003128a13840d6c1e183fb80
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: arm64-randconfig-s031-20200821 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.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.2-191-g10164920-dirty
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm64 

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


sparse warnings: (new ones prefixed by >>)

   drivers/char/lrng/lrng_drng.c:381:6: sparse: sparse: symbol 'lrng_reset' was not declared. Should it be static?
--
>> drivers/char/lrng/lrng_chacha20.c:54:47: sparse: sparse: cast to restricted __le32
   drivers/char/lrng/lrng_chacha20.c:58:47: sparse: sparse: cast to restricted __le32
--
>> drivers/char/lrng/lrng_interfaces.c:482:16: sparse: sparse: incorrect type in return expression (different base types) @@     expected unsigned int @@     got restricted __poll_t [assigned] [usertype] mask @@
>> drivers/char/lrng/lrng_interfaces.c:482:16: sparse:     expected unsigned int
>> drivers/char/lrng/lrng_interfaces.c:482:16: sparse:     got restricted __poll_t [assigned] [usertype] mask
>> drivers/char/lrng/lrng_interfaces.c:612:18: sparse: sparse: incorrect type in initializer (different base types) @@     expected restricted __poll_t ( *poll )( ... ) @@     got unsigned int ( * )( ... ) @@
>> drivers/char/lrng/lrng_interfaces.c:612:18: sparse:     expected restricted __poll_t ( *poll )( ... )
>> drivers/char/lrng/lrng_interfaces.c:612:18: sparse:     got unsigned int ( * )( ... )

# https://github.com/0day-ci/linux/commit/95481f9aadd4408e56c65cd95e47b929224fbc28
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Stephan-M-ller/dev-random-a-new-approach-with-full-SP800-90B-compliance/20200821-140523
git checkout 95481f9aadd4408e56c65cd95e47b929224fbc28
vim +/lrng_drngs_init_cc20 +81 drivers/char/lrng/lrng_drng.c

95481f9aadd440 Stephan Müller 2020-08-21   79  
95481f9aadd440 Stephan Müller 2020-08-21   80  /* Initialize the default DRNG during boot */
95481f9aadd440 Stephan Müller 2020-08-21  @81  static void lrng_drngs_init_cc20(void)
95481f9aadd440 Stephan Müller 2020-08-21   82  {
95481f9aadd440 Stephan Müller 2020-08-21   83  	unsigned long flags = 0;
95481f9aadd440 Stephan Müller 2020-08-21   84  
95481f9aadd440 Stephan Müller 2020-08-21   85  	if (lrng_get_available())
95481f9aadd440 Stephan Müller 2020-08-21   86  		return;
95481f9aadd440 Stephan Müller 2020-08-21   87  
95481f9aadd440 Stephan Müller 2020-08-21   88  	lrng_drng_lock(&lrng_drng_init, &flags);
95481f9aadd440 Stephan Müller 2020-08-21   89  	if (lrng_get_available()) {
95481f9aadd440 Stephan Müller 2020-08-21   90  		lrng_drng_unlock(&lrng_drng_init, &flags);
95481f9aadd440 Stephan Müller 2020-08-21   91  		return;
95481f9aadd440 Stephan Müller 2020-08-21   92  	}
95481f9aadd440 Stephan Müller 2020-08-21   93  
95481f9aadd440 Stephan Müller 2020-08-21   94  	lrng_drng_reset(&lrng_drng_init);
95481f9aadd440 Stephan Müller 2020-08-21   95  	lrng_cc20_init_state(&chacha20);
95481f9aadd440 Stephan Müller 2020-08-21   96  	lrng_state_init_seed_work();
95481f9aadd440 Stephan Müller 2020-08-21   97  	lrng_drng_unlock(&lrng_drng_init, &flags);
95481f9aadd440 Stephan Müller 2020-08-21   98  
95481f9aadd440 Stephan Müller 2020-08-21   99  	lrng_drng_lock(&lrng_drng_atomic, &flags);
95481f9aadd440 Stephan Müller 2020-08-21  100  	lrng_drng_reset(&lrng_drng_atomic);
95481f9aadd440 Stephan Müller 2020-08-21  101  	/*
95481f9aadd440 Stephan Müller 2020-08-21  102  	 * We do not initialize the state of the atomic DRNG as it is identical
95481f9aadd440 Stephan Müller 2020-08-21  103  	 * to the DRNG at this point.
95481f9aadd440 Stephan Müller 2020-08-21  104  	 */
95481f9aadd440 Stephan Müller 2020-08-21  105  	lrng_drng_unlock(&lrng_drng_atomic, &flags);
95481f9aadd440 Stephan Müller 2020-08-21  106  
95481f9aadd440 Stephan Müller 2020-08-21  107  	lrng_set_available();
95481f9aadd440 Stephan Müller 2020-08-21  108  }
95481f9aadd440 Stephan Müller 2020-08-21  109  
95481f9aadd440 Stephan Müller 2020-08-21  110  /************************* Random Number Generation ***************************/
95481f9aadd440 Stephan Müller 2020-08-21  111  
95481f9aadd440 Stephan Müller 2020-08-21  112  /* Inject a data buffer into the DRNG */
95481f9aadd440 Stephan Müller 2020-08-21 @113  static void lrng_drng_inject(struct lrng_drng *drng,
95481f9aadd440 Stephan Müller 2020-08-21  114  			     const u8 *inbuf, u32 inbuflen)
95481f9aadd440 Stephan Müller 2020-08-21  115  {
95481f9aadd440 Stephan Müller 2020-08-21  116  	const char *drng_type = unlikely(drng == &lrng_drng_atomic) ?
95481f9aadd440 Stephan Müller 2020-08-21  117  				"atomic" : "regular";
95481f9aadd440 Stephan Müller 2020-08-21  118  	unsigned long flags = 0;
95481f9aadd440 Stephan Müller 2020-08-21  119  
95481f9aadd440 Stephan Müller 2020-08-21  120  	BUILD_BUG_ON(LRNG_DRNG_RESEED_THRESH > INT_MAX);
95481f9aadd440 Stephan Müller 2020-08-21  121  	pr_debug("seeding %s DRNG with %u bytes\n", drng_type, inbuflen);
95481f9aadd440 Stephan Müller 2020-08-21  122  	lrng_drng_lock(drng, &flags);
95481f9aadd440 Stephan Müller 2020-08-21  123  	if (drng->crypto_cb->lrng_drng_seed_helper(drng->drng,
95481f9aadd440 Stephan Müller 2020-08-21  124  						    inbuf, inbuflen) < 0) {
95481f9aadd440 Stephan Müller 2020-08-21  125  		pr_warn("seeding of %s DRNG failed\n", drng_type);
95481f9aadd440 Stephan Müller 2020-08-21  126  		atomic_set(&drng->requests, 1);
95481f9aadd440 Stephan Müller 2020-08-21  127  	} else {
95481f9aadd440 Stephan Müller 2020-08-21  128  		pr_debug("%s DRNG stats since last seeding: %lu secs; generate calls: %d\n",
95481f9aadd440 Stephan Müller 2020-08-21  129  			 drng_type,
95481f9aadd440 Stephan Müller 2020-08-21  130  			 (time_after(jiffies, drng->last_seeded) ?
95481f9aadd440 Stephan Müller 2020-08-21  131  			  (jiffies - drng->last_seeded) : 0) / HZ,
95481f9aadd440 Stephan Müller 2020-08-21  132  			 (LRNG_DRNG_RESEED_THRESH -
95481f9aadd440 Stephan Müller 2020-08-21  133  			  atomic_read(&drng->requests)));
95481f9aadd440 Stephan Müller 2020-08-21  134  		drng->last_seeded = jiffies;
95481f9aadd440 Stephan Müller 2020-08-21  135  		atomic_set(&drng->requests, LRNG_DRNG_RESEED_THRESH);
95481f9aadd440 Stephan Müller 2020-08-21  136  		drng->force_reseed = false;
95481f9aadd440 Stephan Müller 2020-08-21  137  
95481f9aadd440 Stephan Müller 2020-08-21  138  		if (drng->drng == lrng_drng_atomic.drng) {
95481f9aadd440 Stephan Müller 2020-08-21  139  			lrng_drng_atomic.last_seeded = jiffies;
95481f9aadd440 Stephan Müller 2020-08-21  140  			atomic_set(&lrng_drng_atomic.requests,
95481f9aadd440 Stephan Müller 2020-08-21  141  				   LRNG_DRNG_RESEED_THRESH);
95481f9aadd440 Stephan Müller 2020-08-21  142  			lrng_drng_atomic.force_reseed = false;
95481f9aadd440 Stephan Müller 2020-08-21  143  		}
95481f9aadd440 Stephan Müller 2020-08-21  144  	}
95481f9aadd440 Stephan Müller 2020-08-21  145  	lrng_drng_unlock(drng, &flags);
95481f9aadd440 Stephan Müller 2020-08-21  146  }
95481f9aadd440 Stephan Müller 2020-08-21  147  
95481f9aadd440 Stephan Müller 2020-08-21  148  /*
95481f9aadd440 Stephan Müller 2020-08-21  149   * Perform the seeding of the DRNG with data from noise source
95481f9aadd440 Stephan Müller 2020-08-21  150   */
95481f9aadd440 Stephan Müller 2020-08-21  151  static inline int _lrng_drng_seed(struct lrng_drng *drng)
95481f9aadd440 Stephan Müller 2020-08-21  152  {
95481f9aadd440 Stephan Müller 2020-08-21  153  	struct entropy_buf seedbuf __aligned(LRNG_KCAPI_ALIGN);
95481f9aadd440 Stephan Müller 2020-08-21  154  	unsigned long flags = 0;
95481f9aadd440 Stephan Müller 2020-08-21  155  	u32 total_entropy_bits;
95481f9aadd440 Stephan Müller 2020-08-21  156  	int ret;
95481f9aadd440 Stephan Müller 2020-08-21  157  
95481f9aadd440 Stephan Müller 2020-08-21  158  	lrng_drng_lock(drng, &flags);
95481f9aadd440 Stephan Müller 2020-08-21  159  	total_entropy_bits = lrng_fill_seed_buffer(drng->crypto_cb, drng->hash,
95481f9aadd440 Stephan Müller 2020-08-21  160  						   &seedbuf, 0);
95481f9aadd440 Stephan Müller 2020-08-21 @161  	lrng_drng_unlock(drng, &flags);
95481f9aadd440 Stephan Müller 2020-08-21  162  
95481f9aadd440 Stephan Müller 2020-08-21  163  	/* Allow the seeding operation to be called again */
95481f9aadd440 Stephan Müller 2020-08-21  164  	lrng_pool_unlock();
95481f9aadd440 Stephan Müller 2020-08-21  165  	lrng_init_ops(total_entropy_bits);
95481f9aadd440 Stephan Müller 2020-08-21  166  	ret = total_entropy_bits >> 3;
95481f9aadd440 Stephan Müller 2020-08-21  167  
95481f9aadd440 Stephan Müller 2020-08-21  168  	lrng_drng_inject(drng, (u8 *)&seedbuf, sizeof(seedbuf));
95481f9aadd440 Stephan Müller 2020-08-21  169  	memzero_explicit(&seedbuf, sizeof(seedbuf));
95481f9aadd440 Stephan Müller 2020-08-21  170  
95481f9aadd440 Stephan Müller 2020-08-21  171  	return ret;
95481f9aadd440 Stephan Müller 2020-08-21  172  }
95481f9aadd440 Stephan Müller 2020-08-21  173  

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux