* [linux-next:master 4504/9053] arch/s390/crypto/phmac_s390.c:318:17-18: WARNING: Unsigned expression compared with zero: k > 0
@ 2025-07-14 6:17 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-07-14 6:17 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Harald Freudenberger <freude@linux.ibm.com>
CC: Herbert Xu <herbert@gondor.apana.org.au>
CC: Holger Dengler <dengler@linux.ibm.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: a62b7a37e6fcf4a675b1548e7c168b96ec836442
commit: cbbc675506cc4cd93e6f895e7c1f693156f9a95c [4504/9053] crypto: s390 - New s390 specific protected key hash phmac
:::::: branch date: 3 days ago
:::::: commit date: 3 weeks ago
config: s390-randconfig-r054-20250714 (https://download.01.org/0day-ci/archive/20250714/202507141415.H677CuC5-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 01c97b4953e87ae455bd4c41e3de3f0f0f29c61c)
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>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507141415.H677CuC5-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> arch/s390/crypto/phmac_s390.c:318:17-18: WARNING: Unsigned expression compared with zero: k > 0
arch/s390/crypto/phmac_s390.c:355:14-15: WARNING: Unsigned expression compared with zero: k > 0
arch/s390/crypto/phmac_s390.c:416:15-16: WARNING: Unsigned expression compared with zero: k > 0
vim +318 arch/s390/crypto/phmac_s390.c
cbbc675506cc4c Harald Freudenberger 2025-06-17 284
cbbc675506cc4c Harald Freudenberger 2025-06-17 285 static int phmac_kmac_update(struct ahash_request *req, bool maysleep)
cbbc675506cc4c Harald Freudenberger 2025-06-17 286 {
cbbc675506cc4c Harald Freudenberger 2025-06-17 287 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
cbbc675506cc4c Harald Freudenberger 2025-06-17 288 struct phmac_tfm_ctx *tfm_ctx = crypto_ahash_ctx(tfm);
cbbc675506cc4c Harald Freudenberger 2025-06-17 289 struct phmac_req_ctx *req_ctx = ahash_request_ctx(req);
cbbc675506cc4c Harald Freudenberger 2025-06-17 290 struct kmac_sha2_ctx *ctx = &req_ctx->kmac_ctx;
cbbc675506cc4c Harald Freudenberger 2025-06-17 291 struct hash_walk_helper *hwh = &req_ctx->hwh;
cbbc675506cc4c Harald Freudenberger 2025-06-17 292 unsigned int bs = crypto_ahash_blocksize(tfm);
cbbc675506cc4c Harald Freudenberger 2025-06-17 293 unsigned int offset, k, n;
cbbc675506cc4c Harald Freudenberger 2025-06-17 294 int rc = 0;
cbbc675506cc4c Harald Freudenberger 2025-06-17 295
cbbc675506cc4c Harald Freudenberger 2025-06-17 296 /*
cbbc675506cc4c Harald Freudenberger 2025-06-17 297 * The walk is always mapped when this function is called.
cbbc675506cc4c Harald Freudenberger 2025-06-17 298 * Note that in case of partial processing or failure the walk
cbbc675506cc4c Harald Freudenberger 2025-06-17 299 * is NOT unmapped here. So a follow up task may reuse the walk
cbbc675506cc4c Harald Freudenberger 2025-06-17 300 * or in case of unrecoverable failure needs to unmap it.
cbbc675506cc4c Harald Freudenberger 2025-06-17 301 */
cbbc675506cc4c Harald Freudenberger 2025-06-17 302
cbbc675506cc4c Harald Freudenberger 2025-06-17 303 while (hwh->walkbytes > 0) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 304 /* check sha2 context buffer */
cbbc675506cc4c Harald Freudenberger 2025-06-17 305 offset = ctx->buflen[0] % bs;
cbbc675506cc4c Harald Freudenberger 2025-06-17 306 if (offset + hwh->walkbytes < bs)
cbbc675506cc4c Harald Freudenberger 2025-06-17 307 goto store;
cbbc675506cc4c Harald Freudenberger 2025-06-17 308
cbbc675506cc4c Harald Freudenberger 2025-06-17 309 if (offset) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 310 /* fill ctx buffer up to blocksize and process this block */
cbbc675506cc4c Harald Freudenberger 2025-06-17 311 n = bs - offset;
cbbc675506cc4c Harald Freudenberger 2025-06-17 312 memcpy(ctx->buf + offset, hwh->walkaddr, n);
cbbc675506cc4c Harald Freudenberger 2025-06-17 313 ctx->gr0.iimp = 1;
cbbc675506cc4c Harald Freudenberger 2025-06-17 314 for (;;) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 315 k = _cpacf_kmac(&ctx->gr0.reg, ctx->param, ctx->buf, bs);
cbbc675506cc4c Harald Freudenberger 2025-06-17 316 if (likely(k == bs))
cbbc675506cc4c Harald Freudenberger 2025-06-17 317 break;
cbbc675506cc4c Harald Freudenberger 2025-06-17 @318 if (unlikely(k > 0)) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 319 /*
cbbc675506cc4c Harald Freudenberger 2025-06-17 320 * Can't deal with hunks smaller than blocksize.
cbbc675506cc4c Harald Freudenberger 2025-06-17 321 * And kmac should always return the nr of
cbbc675506cc4c Harald Freudenberger 2025-06-17 322 * processed bytes as 0 or a multiple of the
cbbc675506cc4c Harald Freudenberger 2025-06-17 323 * blocksize.
cbbc675506cc4c Harald Freudenberger 2025-06-17 324 */
cbbc675506cc4c Harald Freudenberger 2025-06-17 325 rc = -EIO;
cbbc675506cc4c Harald Freudenberger 2025-06-17 326 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 327 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 328 /* protected key is invalid and needs re-conversion */
cbbc675506cc4c Harald Freudenberger 2025-06-17 329 if (!maysleep) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 330 rc = -EKEYEXPIRED;
cbbc675506cc4c Harald Freudenberger 2025-06-17 331 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 332 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 333 rc = phmac_convert_key(tfm_ctx);
cbbc675506cc4c Harald Freudenberger 2025-06-17 334 if (rc)
cbbc675506cc4c Harald Freudenberger 2025-06-17 335 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 336 spin_lock_bh(&tfm_ctx->pk_lock);
cbbc675506cc4c Harald Freudenberger 2025-06-17 337 memcpy(ctx->param + SHA2_KEY_OFFSET(bs),
cbbc675506cc4c Harald Freudenberger 2025-06-17 338 tfm_ctx->pk.protkey, tfm_ctx->pk.len);
cbbc675506cc4c Harald Freudenberger 2025-06-17 339 spin_unlock_bh(&tfm_ctx->pk_lock);
cbbc675506cc4c Harald Freudenberger 2025-06-17 340 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 341 ctx->buflen[0] += n;
cbbc675506cc4c Harald Freudenberger 2025-06-17 342 if (ctx->buflen[0] < n)
cbbc675506cc4c Harald Freudenberger 2025-06-17 343 ctx->buflen[1]++;
cbbc675506cc4c Harald Freudenberger 2025-06-17 344 rc = hwh_advance(hwh, n);
cbbc675506cc4c Harald Freudenberger 2025-06-17 345 if (unlikely(rc))
cbbc675506cc4c Harald Freudenberger 2025-06-17 346 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 347 offset = 0;
cbbc675506cc4c Harald Freudenberger 2025-06-17 348 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 349
cbbc675506cc4c Harald Freudenberger 2025-06-17 350 /* process as many blocks as possible from the walk */
cbbc675506cc4c Harald Freudenberger 2025-06-17 351 while (hwh->walkbytes >= bs) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 352 n = (hwh->walkbytes / bs) * bs;
cbbc675506cc4c Harald Freudenberger 2025-06-17 353 ctx->gr0.iimp = 1;
cbbc675506cc4c Harald Freudenberger 2025-06-17 354 k = _cpacf_kmac(&ctx->gr0.reg, ctx->param, hwh->walkaddr, n);
cbbc675506cc4c Harald Freudenberger 2025-06-17 355 if (likely(k > 0)) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 356 ctx->buflen[0] += k;
cbbc675506cc4c Harald Freudenberger 2025-06-17 357 if (ctx->buflen[0] < k)
cbbc675506cc4c Harald Freudenberger 2025-06-17 358 ctx->buflen[1]++;
cbbc675506cc4c Harald Freudenberger 2025-06-17 359 rc = hwh_advance(hwh, k);
cbbc675506cc4c Harald Freudenberger 2025-06-17 360 if (unlikely(rc))
cbbc675506cc4c Harald Freudenberger 2025-06-17 361 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 362 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 363 if (unlikely(k < n)) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 364 /* protected key is invalid and needs re-conversion */
cbbc675506cc4c Harald Freudenberger 2025-06-17 365 if (!maysleep) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 366 rc = -EKEYEXPIRED;
cbbc675506cc4c Harald Freudenberger 2025-06-17 367 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 368 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 369 rc = phmac_convert_key(tfm_ctx);
cbbc675506cc4c Harald Freudenberger 2025-06-17 370 if (rc)
cbbc675506cc4c Harald Freudenberger 2025-06-17 371 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 372 spin_lock_bh(&tfm_ctx->pk_lock);
cbbc675506cc4c Harald Freudenberger 2025-06-17 373 memcpy(ctx->param + SHA2_KEY_OFFSET(bs),
cbbc675506cc4c Harald Freudenberger 2025-06-17 374 tfm_ctx->pk.protkey, tfm_ctx->pk.len);
cbbc675506cc4c Harald Freudenberger 2025-06-17 375 spin_unlock_bh(&tfm_ctx->pk_lock);
cbbc675506cc4c Harald Freudenberger 2025-06-17 376 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 377 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 378
cbbc675506cc4c Harald Freudenberger 2025-06-17 379 store:
cbbc675506cc4c Harald Freudenberger 2025-06-17 380 /* store incomplete block in context buffer */
cbbc675506cc4c Harald Freudenberger 2025-06-17 381 if (hwh->walkbytes) {
cbbc675506cc4c Harald Freudenberger 2025-06-17 382 memcpy(ctx->buf + offset, hwh->walkaddr, hwh->walkbytes);
cbbc675506cc4c Harald Freudenberger 2025-06-17 383 ctx->buflen[0] += hwh->walkbytes;
cbbc675506cc4c Harald Freudenberger 2025-06-17 384 if (ctx->buflen[0] < hwh->walkbytes)
cbbc675506cc4c Harald Freudenberger 2025-06-17 385 ctx->buflen[1]++;
cbbc675506cc4c Harald Freudenberger 2025-06-17 386 rc = hwh_advance(hwh, hwh->walkbytes);
cbbc675506cc4c Harald Freudenberger 2025-06-17 387 if (unlikely(rc))
cbbc675506cc4c Harald Freudenberger 2025-06-17 388 goto out;
cbbc675506cc4c Harald Freudenberger 2025-06-17 389 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 390
cbbc675506cc4c Harald Freudenberger 2025-06-17 391 } /* end of while (hwh->walkbytes > 0) */
cbbc675506cc4c Harald Freudenberger 2025-06-17 392
cbbc675506cc4c Harald Freudenberger 2025-06-17 393 out:
cbbc675506cc4c Harald Freudenberger 2025-06-17 394 pr_debug("rc=%d\n", rc);
cbbc675506cc4c Harald Freudenberger 2025-06-17 395 return rc;
cbbc675506cc4c Harald Freudenberger 2025-06-17 396 }
cbbc675506cc4c Harald Freudenberger 2025-06-17 397
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-07-14 6:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 6:17 [linux-next:master 4504/9053] arch/s390/crypto/phmac_s390.c:318:17-18: WARNING: Unsigned expression compared with zero: k > 0 kernel test robot
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.