* [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)'
@ 2026-08-08 0:58 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-08-08 0:58 UTC (permalink / raw)
To: Eric Biggers; +Cc: oe-kbuild-all, Ard Biesheuvel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-08 0:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-08 0:58 [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)' 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.