* crypto/testmgr.c:646:39: sparse: signed value source
@ 2025-10-21 14:09 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-10-21 14:09 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence static check warning: crypto/testmgr.c:646:39: sparse: signed value source"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Eric Biggers <ebiggers@google.com>
CC: Herbert Xu <herbert@gondor.apana.org.au>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 6548d364a3e850326831799d7e3ea2d7bb97ba08
commit: 40b9969796bfa49ed1b0f7ddc254f48cb2ac6d2c crypto: testmgr - replace CRYPTO_MANAGER_DISABLE_TESTS with CRYPTO_SELFTESTS
date: 5 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 5 months ago
config: m68k-randconfig-r131-20251021 (https://download.01.org/0day-ci/archive/20251021/202510212228.P0Hs7pPy-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251021/202510212228.P0Hs7pPy-lkp@intel.com/reproduce)
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/r/202510212228.P0Hs7pPy-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
crypto/testmgr.c: note: in included file:
include/linux/scatterlist.h:187:9: sparse: sparse: unsigned value that used to be signed checked against zero?
>> crypto/testmgr.c:646:39: sparse: signed value source
include/linux/scatterlist.h:187:9: sparse: sparse: unsigned value that used to be signed checked against zero?
crypto/testmgr.c:4002:37: sparse: signed value source
include/linux/scatterlist.h:187:9: sparse: sparse: unsigned value that used to be signed checked against zero?
crypto/testmgr.c:4003:43: sparse: signed value source
vim +646 crypto/testmgr.c
3f47a03df6e8117 Eric Biggers 2019-01-31 570
3f47a03df6e8117 Eric Biggers 2019-01-31 571 /**
3f47a03df6e8117 Eric Biggers 2019-01-31 572 * build_test_sglist() - build a scatterlist for a crypto test
3f47a03df6e8117 Eric Biggers 2019-01-31 573 *
3f47a03df6e8117 Eric Biggers 2019-01-31 574 * @tsgl: the scatterlist to build. @tsgl->bufs[] contains an array of 2-page
3f47a03df6e8117 Eric Biggers 2019-01-31 575 * buffers which the scatterlist @tsgl->sgl[] will be made to point into.
3f47a03df6e8117 Eric Biggers 2019-01-31 576 * @divs: the layout specification on which the scatterlist will be based
3f47a03df6e8117 Eric Biggers 2019-01-31 577 * @alignmask: the algorithm's alignmask
3f47a03df6e8117 Eric Biggers 2019-01-31 578 * @total_len: the total length of the scatterlist to build in bytes
3f47a03df6e8117 Eric Biggers 2019-01-31 579 * @data: if non-NULL, the buffers will be filled with this data until it ends.
3f47a03df6e8117 Eric Biggers 2019-01-31 580 * Otherwise the buffers will be poisoned. In both cases, some bytes
3f47a03df6e8117 Eric Biggers 2019-01-31 581 * past the end of each buffer will be poisoned to help detect overruns.
3f47a03df6e8117 Eric Biggers 2019-01-31 582 * @out_divs: if non-NULL, the test_sg_division to which each scatterlist entry
3f47a03df6e8117 Eric Biggers 2019-01-31 583 * corresponds will be returned here. This will match @divs except
3f47a03df6e8117 Eric Biggers 2019-01-31 584 * that divisions resolving to a length of 0 are omitted as they are
3f47a03df6e8117 Eric Biggers 2019-01-31 585 * not included in the scatterlist.
3f47a03df6e8117 Eric Biggers 2019-01-31 586 *
3f47a03df6e8117 Eric Biggers 2019-01-31 587 * Return: 0 or a -errno value
3f47a03df6e8117 Eric Biggers 2019-01-31 588 */
3f47a03df6e8117 Eric Biggers 2019-01-31 589 static int build_test_sglist(struct test_sglist *tsgl,
3f47a03df6e8117 Eric Biggers 2019-01-31 590 const struct test_sg_division *divs,
3f47a03df6e8117 Eric Biggers 2019-01-31 591 const unsigned int alignmask,
3f47a03df6e8117 Eric Biggers 2019-01-31 592 const unsigned int total_len,
3f47a03df6e8117 Eric Biggers 2019-01-31 593 struct iov_iter *data,
3f47a03df6e8117 Eric Biggers 2019-01-31 594 const struct test_sg_division *out_divs[XBUFSIZE])
3f47a03df6e8117 Eric Biggers 2019-01-31 595 {
3f47a03df6e8117 Eric Biggers 2019-01-31 596 struct {
3f47a03df6e8117 Eric Biggers 2019-01-31 597 const struct test_sg_division *div;
3f47a03df6e8117 Eric Biggers 2019-01-31 598 size_t length;
3f47a03df6e8117 Eric Biggers 2019-01-31 599 } partitions[XBUFSIZE];
3f47a03df6e8117 Eric Biggers 2019-01-31 600 const unsigned int ndivs = count_test_sg_divisions(divs);
3f47a03df6e8117 Eric Biggers 2019-01-31 601 unsigned int len_remaining = total_len;
3f47a03df6e8117 Eric Biggers 2019-01-31 602 unsigned int i;
3f47a03df6e8117 Eric Biggers 2019-01-31 603
3f47a03df6e8117 Eric Biggers 2019-01-31 604 BUILD_BUG_ON(ARRAY_SIZE(partitions) != ARRAY_SIZE(tsgl->sgl));
3f47a03df6e8117 Eric Biggers 2019-01-31 605 if (WARN_ON(ndivs > ARRAY_SIZE(partitions)))
3f47a03df6e8117 Eric Biggers 2019-01-31 606 return -EINVAL;
3f47a03df6e8117 Eric Biggers 2019-01-31 607
3f47a03df6e8117 Eric Biggers 2019-01-31 608 /* Calculate the (div, length) pairs */
3f47a03df6e8117 Eric Biggers 2019-01-31 609 tsgl->nents = 0;
3f47a03df6e8117 Eric Biggers 2019-01-31 610 for (i = 0; i < ndivs; i++) {
3f47a03df6e8117 Eric Biggers 2019-01-31 611 unsigned int len_this_sg =
3f47a03df6e8117 Eric Biggers 2019-01-31 612 min(len_remaining,
3f47a03df6e8117 Eric Biggers 2019-01-31 613 (total_len * divs[i].proportion_of_total +
3f47a03df6e8117 Eric Biggers 2019-01-31 614 TEST_SG_TOTAL / 2) / TEST_SG_TOTAL);
3f47a03df6e8117 Eric Biggers 2019-01-31 615
3f47a03df6e8117 Eric Biggers 2019-01-31 616 if (len_this_sg != 0) {
3f47a03df6e8117 Eric Biggers 2019-01-31 617 partitions[tsgl->nents].div = &divs[i];
3f47a03df6e8117 Eric Biggers 2019-01-31 618 partitions[tsgl->nents].length = len_this_sg;
3f47a03df6e8117 Eric Biggers 2019-01-31 619 tsgl->nents++;
3f47a03df6e8117 Eric Biggers 2019-01-31 620 len_remaining -= len_this_sg;
3f47a03df6e8117 Eric Biggers 2019-01-31 621 }
3f47a03df6e8117 Eric Biggers 2019-01-31 622 }
3f47a03df6e8117 Eric Biggers 2019-01-31 623 if (tsgl->nents == 0) {
3f47a03df6e8117 Eric Biggers 2019-01-31 624 partitions[tsgl->nents].div = &divs[0];
3f47a03df6e8117 Eric Biggers 2019-01-31 625 partitions[tsgl->nents].length = 0;
3f47a03df6e8117 Eric Biggers 2019-01-31 626 tsgl->nents++;
3f47a03df6e8117 Eric Biggers 2019-01-31 627 }
3f47a03df6e8117 Eric Biggers 2019-01-31 628 partitions[tsgl->nents - 1].length += len_remaining;
3f47a03df6e8117 Eric Biggers 2019-01-31 629
3f47a03df6e8117 Eric Biggers 2019-01-31 630 /* Set up the sgl entries and fill the data or poison */
3f47a03df6e8117 Eric Biggers 2019-01-31 631 sg_init_table(tsgl->sgl, tsgl->nents);
3f47a03df6e8117 Eric Biggers 2019-01-31 632 for (i = 0; i < tsgl->nents; i++) {
3f47a03df6e8117 Eric Biggers 2019-01-31 633 unsigned int offset = partitions[i].div->offset;
3f47a03df6e8117 Eric Biggers 2019-01-31 634 void *addr;
3f47a03df6e8117 Eric Biggers 2019-01-31 635
3f47a03df6e8117 Eric Biggers 2019-01-31 636 if (partitions[i].div->offset_relative_to_alignmask)
3f47a03df6e8117 Eric Biggers 2019-01-31 637 offset += alignmask;
3f47a03df6e8117 Eric Biggers 2019-01-31 638
3f47a03df6e8117 Eric Biggers 2019-01-31 639 while (offset + partitions[i].length + TESTMGR_POISON_LEN >
3f47a03df6e8117 Eric Biggers 2019-01-31 640 2 * PAGE_SIZE) {
3f47a03df6e8117 Eric Biggers 2019-01-31 641 if (WARN_ON(offset <= 0))
3f47a03df6e8117 Eric Biggers 2019-01-31 642 return -EINVAL;
3f47a03df6e8117 Eric Biggers 2019-01-31 643 offset /= 2;
3f47a03df6e8117 Eric Biggers 2019-01-31 644 }
3f47a03df6e8117 Eric Biggers 2019-01-31 645
3f47a03df6e8117 Eric Biggers 2019-01-31 @646 addr = &tsgl->bufs[i][offset];
3f47a03df6e8117 Eric Biggers 2019-01-31 647 sg_set_buf(&tsgl->sgl[i], addr, partitions[i].length);
3f47a03df6e8117 Eric Biggers 2019-01-31 648
3f47a03df6e8117 Eric Biggers 2019-01-31 649 if (out_divs)
3f47a03df6e8117 Eric Biggers 2019-01-31 650 out_divs[i] = partitions[i].div;
3f47a03df6e8117 Eric Biggers 2019-01-31 651
3f47a03df6e8117 Eric Biggers 2019-01-31 652 if (data) {
3f47a03df6e8117 Eric Biggers 2019-01-31 653 size_t copy_len, copied;
3f47a03df6e8117 Eric Biggers 2019-01-31 654
3f47a03df6e8117 Eric Biggers 2019-01-31 655 copy_len = min(partitions[i].length, data->count);
3f47a03df6e8117 Eric Biggers 2019-01-31 656 copied = copy_from_iter(addr, copy_len, data);
3f47a03df6e8117 Eric Biggers 2019-01-31 657 if (WARN_ON(copied != copy_len))
3f47a03df6e8117 Eric Biggers 2019-01-31 658 return -EINVAL;
3f47a03df6e8117 Eric Biggers 2019-01-31 659 testmgr_poison(addr + copy_len, partitions[i].length +
3f47a03df6e8117 Eric Biggers 2019-01-31 660 TESTMGR_POISON_LEN - copy_len);
3f47a03df6e8117 Eric Biggers 2019-01-31 661 } else {
3f47a03df6e8117 Eric Biggers 2019-01-31 662 testmgr_poison(addr, partitions[i].length +
3f47a03df6e8117 Eric Biggers 2019-01-31 663 TESTMGR_POISON_LEN);
3f47a03df6e8117 Eric Biggers 2019-01-31 664 }
3f47a03df6e8117 Eric Biggers 2019-01-31 665 }
3f47a03df6e8117 Eric Biggers 2019-01-31 666
3f47a03df6e8117 Eric Biggers 2019-01-31 667 sg_mark_end(&tsgl->sgl[tsgl->nents - 1]);
3f47a03df6e8117 Eric Biggers 2019-01-31 668 tsgl->sgl_ptr = tsgl->sgl;
3f47a03df6e8117 Eric Biggers 2019-01-31 669 memcpy(tsgl->sgl_saved, tsgl->sgl, tsgl->nents * sizeof(tsgl->sgl[0]));
3f47a03df6e8117 Eric Biggers 2019-01-31 670 return 0;
3f47a03df6e8117 Eric Biggers 2019-01-31 671 }
3f47a03df6e8117 Eric Biggers 2019-01-31 672
:::::: The code at line 646 was first introduced by commit
:::::: 3f47a03df6e81174558f4604828851cb600e1db6 crypto: testmgr - add testvec_config struct and helper functions
:::::: TO: Eric Biggers <ebiggers@google.com>
:::::: CC: Herbert Xu <herbert@gondor.apana.org.au>
--
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-10-21 14:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 14:09 crypto/testmgr.c:646:39: sparse: signed value source 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.