CC: [email protected]
CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Hannes Reinecke <[email protected]>

Hi Hannes,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.16-rc1 next-20211118]
[cannot apply to herbert-cryptodev-2.6/master herbert-crypto-2.6/master 
linux-nvme/for-next]
[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/Hannes-Reinecke/nvme-In-band-authentication-support/20211112-210112
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
5833291ab6de9c3e2374336b51c814e515e8f3a5
:::::: branch date: 8 days ago
:::::: commit date: 8 days ago
config: riscv-randconfig-c006-20211118 (attached as .config)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 
https://github.com/0day-ci/linux/commit/306a253f85fb90aad03f8a14436907c2d96f4d55
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review 
Hannes-Reinecke/nvme-In-band-authentication-support/20211112-210112
        git checkout 306a253f85fb90aad03f8a14436907c2d96f4d55
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
   drivers/nvme/host/auth.c:929:8: note: Calling 
'nvme_auth_dhchap_host_response'
           ret = nvme_auth_dhchap_host_response(ctrl, chap);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:659:2: note: Taking false branch
           dev_dbg(ctrl->device, "%s: qid %d host response seq %d transaction 
%d\n",
           ^
   include/linux/dev_printk.h:162:2: note: expanded from macro 'dev_dbg'
           if (0)                                                          \
           ^
   drivers/nvme/host/auth.c:662:13: note: Field 'host_response' is null
           if (!chap->host_response) {
                      ^
   drivers/nvme/host/auth.c:662:2: note: Taking true branch
           if (!chap->host_response) {
           ^
   drivers/nvme/host/auth.c:663:25: note: Calling 'nvme_auth_transform_key'
                   chap->host_response = 
nvme_auth_transform_key(ctrl->dhchap_key,
                                         
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:249:26: note: Calling 'nvme_auth_hmac_name'
           const char *hmac_name = nvme_auth_hmac_name(key_hash);
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:146:2: note: Loop condition is true.  Entering loop 
body
           for (i = 0; i < ARRAY_SIZE(hash_map); i++) {
           ^
   drivers/nvme/host/auth.c:147:7: note: Assuming 'hmac_id' is equal to field 
'id'
                   if (hash_map[i].id == hmac_id)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:147:3: note: Taking true branch
                   if (hash_map[i].id == hmac_id)
                   ^
   drivers/nvme/host/auth.c:148:4: note: Returning pointer, which participates 
in a condition later
                           return hash_map[i].hmac;
                           ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:249:26: note: Returning from 'nvme_auth_hmac_name'
           const char *hmac_name = nvme_auth_hmac_name(key_hash);
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:252:2: note: 'transformed_key' declared without an 
initial value
           u8 *transformed_key;
           ^~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:255:6: note: Assuming 'key_hash' is not equal to 0
           if (key_hash == 0) {
               ^~~~~~~~~~~~~
   drivers/nvme/host/auth.c:255:2: note: Taking false branch
           if (key_hash == 0) {
           ^
   drivers/nvme/host/auth.c:260:6: note: Assuming 'key' is non-null
           if (!key || !key_len) {
               ^~~~
   drivers/nvme/host/auth.c:260:6: note: Left side of '||' is false
   drivers/nvme/host/auth.c:260:14: note: Assuming 'key_len' is not equal to 0
           if (!key || !key_len) {
                       ^~~~~~~~
   drivers/nvme/host/auth.c:260:2: note: Taking false branch
           if (!key || !key_len) {
           ^
   drivers/nvme/host/auth.c:264:7: note: 'hmac_name' is non-null
           if (!hmac_name) {
                ^~~~~~~~~
   drivers/nvme/host/auth.c:264:2: note: Taking false branch
           if (!hmac_name) {
           ^
   drivers/nvme/host/auth.c:270:6: note: Calling 'IS_ERR'
           if (IS_ERR(key_tfm))
               ^~~~~~~~~~~~~~~
   include/linux/err.h:36:9: note: Assuming the condition is false
           return IS_ERR_VALUE((unsigned long)ptr);
                  ^
   include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
   #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned 
long)-MAX_ERRNO)
                           
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   include/linux/err.h:36:2: note: Returning zero, which participates in a 
condition later
           return IS_ERR_VALUE((unsigned long)ptr);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:270:6: note: Returning from 'IS_ERR'
           if (IS_ERR(key_tfm))
               ^~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:270:2: note: Taking false branch
           if (IS_ERR(key_tfm))
           ^
   drivers/nvme/host/auth.c:276:6: note: Assuming 'shash' is null
           if (!shash) {
               ^~~~~~
   drivers/nvme/host/auth.c:276:2: note: Taking true branch
           if (!shash) {
           ^
   drivers/nvme/host/auth.c:278:3: note: Control jumps to line 304
                   goto out_free_key;
                   ^
   drivers/nvme/host/auth.c:305:6: note: 'ret' is < 0
           if (ret < 0) {
               ^~~
   drivers/nvme/host/auth.c:305:2: note: Taking true branch
           if (ret < 0) {
           ^
   drivers/nvme/host/auth.c:306:3: note: 1st function call argument is an 
uninitialized value
                   kfree_sensitive(transformed_key);
                   ^               ~~~~~~~~~~~~~~~
>> drivers/nvme/host/auth.c:821:23: warning: Assigned value is garbage or 
>> undefined [clang-analyzer-core.uninitialized.Assign]
           ctrl->dhchap_key_len = key_len;
                                ^
   drivers/nvme/host/auth.c:1125:2: note: Loop condition is false.  Exiting loop
           INIT_WORK(&ctrl->dhchap_auth_work, nvme_dhchap_auth_work);
           ^
   include/linux/workqueue.h:245:2: note: expanded from macro 'INIT_WORK'
           __INIT_WORK((_work), (_func), 0)
           ^
   include/linux/workqueue.h:225:2: note: expanded from macro '__INIT_WORK'
           do {                                                            \
           ^
   drivers/nvme/host/auth.c:1126:2: note: Loop condition is false.  Exiting loop
           mutex_init(&ctrl->dhchap_auth_mutex);
           ^
   include/linux/mutex.h:101:32: note: expanded from macro 'mutex_init'
   #define mutex_init(mutex)                                               \
                                                                           ^
   drivers/nvme/host/auth.c:1127:2: note: Calling 'nvme_auth_generate_key'
           nvme_auth_generate_key(ctrl);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:801:2: note: 'key_len' declared without an initial 
value
           size_t key_len;
           ^~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:804:6: note: Assuming 'secret' is non-null
           if (!secret)
               ^~~~~~~
   drivers/nvme/host/auth.c:804:2: note: Taking false branch
           if (!secret)
           ^
   drivers/nvme/host/auth.c:807:6: note: Assuming the condition is false
           if (sscanf(secret, "DHHC-1:%hhd:%*s:", &key_hash) != 1)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:807:2: note: Taking false branch
           if (sscanf(secret, "DHHC-1:%hhd:%*s:", &key_hash) != 1)
           ^
   drivers/nvme/host/auth.c:811:8: note: Calling 'nvme_auth_extract_secret'
           key = nvme_auth_extract_secret(secret + 10, key_hash,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:201:6: note: Assuming 'p' is null
           if (p)
               ^
   drivers/nvme/host/auth.c:201:2: note: Taking false branch
           if (p)
           ^
   drivers/nvme/host/auth.c:204:6: note: Assuming 'key' is non-null
           if (!key)
               ^~~~
   drivers/nvme/host/auth.c:204:2: note: Taking false branch
           if (!key)
           ^
   drivers/nvme/host/auth.c:208:6: note: Assuming 'key_len' is < 0
           if (key_len < 0) {
               ^~~~~~~~~~~
   drivers/nvme/host/auth.c:208:2: note: Taking true branch
           if (key_len < 0) {
           ^
   drivers/nvme/host/auth.c:209:3: note: Taking false branch
                   pr_debug("base64 key decoding error %d\n",
                   ^
   include/linux/printk.h:576:2: note: expanded from macro 'pr_debug'
           no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:131:2: note: expanded from macro 'no_printk'
           if (0)                                          \
           ^
   drivers/nvme/host/auth.c:211:3: note: Returning without writing to '*'
                   return ERR_PTR(key_len);
                   ^
   drivers/nvme/host/auth.c:811:8: note: Returning from 
'nvme_auth_extract_secret'
           key = nvme_auth_extract_secret(secret + 10, key_hash,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:813:6: note: Calling 'IS_ERR'
           if (IS_ERR(key)) {
               ^~~~~~~~~~~
   include/linux/err.h:36:9: note: Assuming the condition is false
           return IS_ERR_VALUE((unsigned long)ptr);
                  ^
   include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
   #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned 
long)-MAX_ERRNO)
                           
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   include/linux/err.h:36:2: note: Returning zero, which participates in a 
condition later
           return IS_ERR_VALUE((unsigned long)ptr);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/auth.c:813:6: note: Returning from 'IS_ERR'
           if (IS_ERR(key)) {
               ^~~~~~~~~~~
   drivers/nvme/host/auth.c:813:2: note: Taking false branch
           if (IS_ERR(key)) {
           ^
   drivers/nvme/host/auth.c:821:23: note: Assigned value is garbage or undefined
           ctrl->dhchap_key_len = key_len;
                                ^ ~~~~~~~
   drivers/nvme/host/auth.c:849:28: warning: Assigned value is garbage or 
undefined [clang-analyzer-core.uninitialized.Assign]
           ctrl->dhchap_ctrl_key_len = key_len;
                                     ^
   drivers/nvme/host/auth.c:1125:2: note: Loop condition is false.  Exiting loop
           INIT_WORK(&ctrl->dhchap_auth_work, nvme_dhchap_auth_work);

vim +821 drivers/nvme/host/auth.c

306a253f85fb90 Hannes Reinecke 2021-11-12  796  
306a253f85fb90 Hannes Reinecke 2021-11-12  797  int 
nvme_auth_generate_key(struct nvme_ctrl *ctrl)
306a253f85fb90 Hannes Reinecke 2021-11-12  798  {
306a253f85fb90 Hannes Reinecke 2021-11-12  799          u8 *secret = 
ctrl->opts->dhchap_secret;
306a253f85fb90 Hannes Reinecke 2021-11-12  800          u8 *key;
306a253f85fb90 Hannes Reinecke 2021-11-12  801          size_t key_len;
306a253f85fb90 Hannes Reinecke 2021-11-12  802          u8 key_hash;
306a253f85fb90 Hannes Reinecke 2021-11-12  803  
306a253f85fb90 Hannes Reinecke 2021-11-12  804          if (!secret)
306a253f85fb90 Hannes Reinecke 2021-11-12  805                  return 0;
306a253f85fb90 Hannes Reinecke 2021-11-12  806  
306a253f85fb90 Hannes Reinecke 2021-11-12  807          if (sscanf(secret, 
"DHHC-1:%hhd:%*s:", &key_hash) != 1)
306a253f85fb90 Hannes Reinecke 2021-11-12  808                  return -EINVAL;
306a253f85fb90 Hannes Reinecke 2021-11-12  809  
306a253f85fb90 Hannes Reinecke 2021-11-12  810          /* Pass in the secret 
without the 'DHHC-1:XX:' prefix */
306a253f85fb90 Hannes Reinecke 2021-11-12  811          key = 
nvme_auth_extract_secret(secret + 10, key_hash,
306a253f85fb90 Hannes Reinecke 2021-11-12  812                                  
       &key_len);
306a253f85fb90 Hannes Reinecke 2021-11-12  813          if (IS_ERR(key)) {
306a253f85fb90 Hannes Reinecke 2021-11-12  814                  
dev_dbg(ctrl->device, "failed to extract key, error %ld\n",
306a253f85fb90 Hannes Reinecke 2021-11-12  815                          
PTR_ERR(key));
306a253f85fb90 Hannes Reinecke 2021-11-12  816                  return 
PTR_ERR(key);
306a253f85fb90 Hannes Reinecke 2021-11-12  817          }
306a253f85fb90 Hannes Reinecke 2021-11-12  818  
306a253f85fb90 Hannes Reinecke 2021-11-12  819          ctrl->dhchap_key = key;
306a253f85fb90 Hannes Reinecke 2021-11-12  820          key = NULL;
306a253f85fb90 Hannes Reinecke 2021-11-12 @821          ctrl->dhchap_key_len = 
key_len;
306a253f85fb90 Hannes Reinecke 2021-11-12  822          ctrl->dhchap_key_hash = 
key_hash;
306a253f85fb90 Hannes Reinecke 2021-11-12  823  
306a253f85fb90 Hannes Reinecke 2021-11-12  824          return 0;
306a253f85fb90 Hannes Reinecke 2021-11-12  825  }
306a253f85fb90 Hannes Reinecke 2021-11-12  826  
EXPORT_SYMBOL_GPL(nvme_auth_generate_key);
306a253f85fb90 Hannes Reinecke 2021-11-12  827  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to