From: kernel test robot <lkp@intel.com>
To: Hannes Reinecke <hare@kernel.org>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [hare-nvme:dhchap-keyring.v4 2/9] drivers/nvme/common/keyring.c:431 nvme_dhchap_psk_read() warn: unsigned 'keylen' is never less than zero.
Date: Fri, 20 Nov 2026 15:44:54 +0100 [thread overview]
Message-ID: <20261120154221.OPwO7MEW-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/hare/nvme.git dhchap-keyring.v4
head: 1b78746d90bfa570d96e88475983421f24c38b0d
commit: a6c7217c8a4b404d6107aeaf07b1323df6adbf32 [2/9] nvme-keyring: add 'dhchap' key type
config: m68k-randconfig-2200-20261120 (https://download.01.org/0day-ci/archive/20261120/20261120154221.OPwO7MEW-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.4.0
smatch: v0.5.0-9187-g5189e3fb
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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261120154221.OPwO7MEW-lkp@intel.com/
smatch warnings:
drivers/nvme/common/keyring.c:431 nvme_dhchap_psk_read() warn: unsigned 'keylen' is never less than zero.
vim +/keylen +431 drivers/nvme/common/keyring.c
396
397 /**
398 * nvme_dhchap_psk_read - read callback for dhchap key types
399 * @key: key to read from
400 * @buffer: buffer for the key contents
401 * @buflen: length of @buffer
402 *
403 * Formets the DH-HMAC-CHAP key in base64-encoded form as
404 * defined in the NVM Express TCP Transport Specification Rev 1.1,
405 * Section 3.6.1.5 'PSK Interchange Format'. The payload of @key
406 * is assumed to be of 'struct user_key_payload', with the data
407 * consisting of the key data of length 'upayload->datalen', followed
408 * by four bytes of CRC, one byte version, and one byte hmac fields.
409 */
410 static long nvme_dhchap_psk_read(const struct key *key,
411 char *buffer, size_t buflen)
412 {
413 const struct user_key_payload *upayload;
414 size_t datalen, keylen;
415 u8 version, hmac;
416 long ret;
417
418 upayload = user_key_payload_locked(key);
419 /*
420 * Expected output string length:
421 * strlen("DHHC-") +
422 * version (= 1) +
423 * ':' (= 1) +
424 * hmac (= 2) +
425 * ':' (= 1) +
426 * encoded base64 key length +
427 * CRC length (= 4) +
428 * ':' (= 1)
429 */
430 keylen = nvme_dhchap_decoded_key_size(upayload->datalen) + 15;
> 431 if (keylen < 0 || !buffer || buflen == 0)
432 return keylen;
433
434 if (buflen < keylen)
435 return -EINVAL;
436
437 memset(buffer, 0, buflen);
438 version = upayload->data[upayload->datalen + 4];
439 hmac = upayload->data[upayload->datalen + 5];
440 ret = sprintf(buffer, "DHHC-%01hhu:%02hhu:", version, hmac);
441 if (ret < 0)
442 return -ENOKEY;
443 /* Include the trailing CRC */
444 datalen = upayload->datalen + 4;
445 ret += base64_encode(upayload->data, datalen, buffer + ret,
446 true, BASE64_STD);
447 buffer[ret] = ':';
448 ret++;
449 return ret;
450 }
451
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-11-20 14:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120154221.OPwO7MEW-lkp@intel.com \
--to=lkp@intel.com \
--cc=hare@kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.