[PATCH] KEYS: remove redundant memsets

kernel test robot lkp at intel.com
Wed Jul 22 06:42:57 UTC 2020


Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on security/next-testing]
[also build test WARNING on linus/master dhowells-fs/fscache-next v5.8-rc6 next-20200721]
[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/trix-redhat-com/KEYS-remove-redundant-memsets/20200721-221633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-testing
config: microblaze-randconfig-r022-20200719 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
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
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze 

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

All warnings (new ones prefixed by >>):

   security/keys/keyctl_pkey.c: In function 'keyctl_pkey_params_get_2':
>> security/keys/keyctl_pkey.c:122:8: warning: 'uparams.key_id' is used uninitialized in this function [-Wuninitialized]
     122 |  ret = keyctl_pkey_params_get(uparams.key_id, _info, params);
         |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +122 security/keys/keyctl_pkey.c

00d60fd3b93219 David Howells 2018-10-09  108  
00d60fd3b93219 David Howells 2018-10-09  109  /*
00d60fd3b93219 David Howells 2018-10-09  110   * Get parameters from userspace.  Callers must always call the free function
00d60fd3b93219 David Howells 2018-10-09  111   * on params, even if an error is returned.
00d60fd3b93219 David Howells 2018-10-09  112   */
00d60fd3b93219 David Howells 2018-10-09  113  static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_params,
00d60fd3b93219 David Howells 2018-10-09  114  				    const char __user *_info,
00d60fd3b93219 David Howells 2018-10-09  115  				    int op,
00d60fd3b93219 David Howells 2018-10-09  116  				    struct kernel_pkey_params *params)
00d60fd3b93219 David Howells 2018-10-09  117  {
00d60fd3b93219 David Howells 2018-10-09  118  	struct keyctl_pkey_params uparams;
00d60fd3b93219 David Howells 2018-10-09  119  	struct kernel_pkey_query info;
00d60fd3b93219 David Howells 2018-10-09  120  	int ret;
00d60fd3b93219 David Howells 2018-10-09  121  
00d60fd3b93219 David Howells 2018-10-09 @122  	ret = keyctl_pkey_params_get(uparams.key_id, _info, params);
00d60fd3b93219 David Howells 2018-10-09  123  	if (ret < 0)
00d60fd3b93219 David Howells 2018-10-09  124  		return ret;
00d60fd3b93219 David Howells 2018-10-09  125  
00d60fd3b93219 David Howells 2018-10-09  126  	ret = params->key->type->asym_query(params, &info);
00d60fd3b93219 David Howells 2018-10-09  127  	if (ret < 0)
00d60fd3b93219 David Howells 2018-10-09  128  		return ret;
00d60fd3b93219 David Howells 2018-10-09  129  
bb67c86855f477 Tom Rix       2020-07-21  130  	if (copy_from_user(&uparams, _params, sizeof(uparams)) != 0)
bb67c86855f477 Tom Rix       2020-07-21  131  		return -EFAULT;
bb67c86855f477 Tom Rix       2020-07-21  132  
00d60fd3b93219 David Howells 2018-10-09  133  	switch (op) {
00d60fd3b93219 David Howells 2018-10-09  134  	case KEYCTL_PKEY_ENCRYPT:
00d60fd3b93219 David Howells 2018-10-09  135  	case KEYCTL_PKEY_DECRYPT:
00d60fd3b93219 David Howells 2018-10-09  136  		if (uparams.in_len  > info.max_enc_size ||
00d60fd3b93219 David Howells 2018-10-09  137  		    uparams.out_len > info.max_dec_size)
00d60fd3b93219 David Howells 2018-10-09  138  			return -EINVAL;
00d60fd3b93219 David Howells 2018-10-09  139  		break;
00d60fd3b93219 David Howells 2018-10-09  140  	case KEYCTL_PKEY_SIGN:
00d60fd3b93219 David Howells 2018-10-09  141  	case KEYCTL_PKEY_VERIFY:
00d60fd3b93219 David Howells 2018-10-09  142  		if (uparams.in_len  > info.max_sig_size ||
00d60fd3b93219 David Howells 2018-10-09  143  		    uparams.out_len > info.max_data_size)
00d60fd3b93219 David Howells 2018-10-09  144  			return -EINVAL;
00d60fd3b93219 David Howells 2018-10-09  145  		break;
00d60fd3b93219 David Howells 2018-10-09  146  	default:
00d60fd3b93219 David Howells 2018-10-09  147  		BUG();
00d60fd3b93219 David Howells 2018-10-09  148  	}
00d60fd3b93219 David Howells 2018-10-09  149  
00d60fd3b93219 David Howells 2018-10-09  150  	params->in_len  = uparams.in_len;
00d60fd3b93219 David Howells 2018-10-09  151  	params->out_len = uparams.out_len;
00d60fd3b93219 David Howells 2018-10-09  152  	return 0;
00d60fd3b93219 David Howells 2018-10-09  153  }
00d60fd3b93219 David Howells 2018-10-09  154  

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


More information about the Linux-security-module-archive mailing list