All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: oe-kbuild-all@lists.linux.dev, Ard Biesheuvel <ardb@kernel.org>
Subject: [linux-next:master 11333/13846] lib/crypto/tests/aes_ccm_kunit.c:317 test_aes_ccm_data_len_too_large() warn: always true condition '(max_data_len + 1 <= (~0)) => (0-u64max <= u64max)'
Date: Sat, 08 Aug 2026 08:58:41 +0800	[thread overview]
Message-ID: <202608080705.p6XFlhbr-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   6b8c8af514d739d0335f5579b585e02babe8a727
commit: 78c1bc21eb055681672da1de139d27865b67d1b2 [11333/13846] lib/crypto: tests: Add KUnit test suite for AES-CCM
config: s390-randconfig-r072-20260807 (https://download.01.org/0day-ci/archive/20260808/202608080705.p6XFlhbr-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 8.5.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/202608080705.p6XFlhbr-lkp@intel.com/

smatch warnings:
lib/crypto/tests/aes_ccm_kunit.c:317 test_aes_ccm_data_len_too_large() warn: always true condition '(max_data_len + 1 <= (~0)) => (0-u64max <= u64max)'

vim +317 lib/crypto/tests/aes_ccm_kunit.c

   261	
   262	/*
   263	 * Test that for each AES-CCM nonce length, the message length is validated
   264	 * against the correct corresponding maximum message length.
   265	 */
   266	static void test_aes_ccm_data_len_too_large(struct kunit *test)
   267	{
   268		static const struct {
   269			size_t nonce_len;
   270			u64 max_data_len;
   271		} lens[] = {
   272			/* clang-format off */
   273			{ 7, 0xffffffffffffffff }, /* U64_MAX */
   274			{ 8, 0xffffffffffffff },
   275			{ 9, 0xffffffffffff },
   276			{ 10, 0xffffffffff },
   277			{ 11, 0xffffffff },
   278			{ 12, 0xffffff },
   279			{ 13, 0xffff },
   280			/* clang-format on */
   281		};
   282		u8 nonce[13] = {};
   283		u8 raw_key[AES_KEYSIZE_256] = {};
   284		int err;
   285		struct aes_ccm_key *key = alloc_buf(test, sizeof(*key));
   286		struct aes_ccm_ctx ctx;
   287	
   288		err = aes_ccm_preparekey(key, raw_key, sizeof(raw_key), 16);
   289		KUNIT_ASSERT_EQ(test, 0, err);
   290	
   291		for (size_t i = 0; i < ARRAY_SIZE(lens); i++) {
   292			size_t nonce_len = lens[i].nonce_len;
   293			u64 max_data_len = lens[i].max_data_len;
   294	
   295			/* data_len <= max_data_len should be accepted. */
   296			err = aes_ccm_init(&ctx, 0, 0, nonce, nonce_len, key);
   297			KUNIT_ASSERT_EQ_MSG(
   298				test, 0, err,
   299				"data_len=0 wasn't accepted with nonce_len=%zu",
   300				nonce_len);
   301			err = aes_ccm_init(&ctx, max_data_len, 0, nonce, nonce_len,
   302					   key);
   303			KUNIT_ASSERT_EQ_MSG(
   304				test, 0, err,
   305				"data_len=%llu wasn't accepted with nonce_len=%zu",
   306				max_data_len, nonce_len);
   307	
   308			/* data_len > max_data_len should be rejected. */
   309			if (max_data_len == U64_MAX)
   310				continue;
   311			err = aes_ccm_init(&ctx, max_data_len + 1, 0, nonce, nonce_len,
   312					   key);
   313			KUNIT_ASSERT_EQ_MSG(
   314				test, -EOVERFLOW, err,
   315				"data_len=%llu wasn't rejected with -EOVERFLOW with nonce_len=%zu (aes_ccm_init)",
   316				max_data_len + 1, nonce_len);
 > 317			if (max_data_len + 1 <= SIZE_MAX) {
   318				err = aes_ccm_encrypt(NULL, NULL, max_data_len + 1,
   319						      NULL, NULL, 0, nonce, nonce_len,
   320						      key);
   321				KUNIT_ASSERT_EQ_MSG(
   322					test, -EOVERFLOW, err,
   323					"data_len=%llu wasn't rejected with -EOVERFLOW with nonce_len=%zu (aes_ccm_encrypt)",
   324					max_data_len + 1, nonce_len);
   325				err = aes_ccm_decrypt(NULL, NULL, max_data_len + 1,
   326						      NULL, NULL, 0, nonce, nonce_len,
   327						      key);
   328				KUNIT_ASSERT_EQ_MSG(
   329					test, -EOVERFLOW, err,
   330					"data_len=%llu wasn't rejected with -EOVERFLOW with nonce_len=%zu (aes_ccm_decrypt)",
   331					max_data_len + 1, nonce_len);
   332			}
   333			err = aes_ccm_init(&ctx, U64_MAX, 0, nonce, nonce_len, key);
   334			KUNIT_ASSERT_EQ_MSG(
   335				test, -EOVERFLOW, err,
   336				"data_len=U64_MAX wasn't rejected with -EOVERFLOW with nonce_len=%zu (aes_ccm_init)",
   337				nonce_len);
   338		}
   339	}
   340	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2026-08-08  0:59 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=202608080705.p6XFlhbr-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=ardb@kernel.org \
    --cc=ebiggers@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.