All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: fortify: add KUnit tests for __counted_by and __counted_by_ptr
@ 2026-09-30 15:56 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-09-30 15:56 UTC (permalink / raw)
  Cc: oe-kbuild-all

Hi Bill,

kernel test robot noticed the following build warnings:



url:    https://github.com/intel-lab-lkp/linux/commits/Bill-Wendling/fortify-add-KUnit-tests-for-__counted_by-and-__counted_by_ptr/20260929-010031
base:   
patch link:    https://lore.kernel.org/r/202609301715.SnFPA5YE-lkp%40intel.com
config: x86_64-randconfig-2300-20260930 (https://download.01.org/0day-ci/archive/20260930/202609301715.SnFPA5YE-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260930/202609301715.SnFPA5YE-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/oe-kbuild-all/202609301715.SnFPA5YE-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   lib/tests/fortify_kunit.c:1049:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
   lib/tests/fortify_kunit.c:1049:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
>> lib/tests/fortify_kunit.c:1049:9: sparse: sparse: incompatible types for operation (==):
   lib/tests/fortify_kunit.c:1049:9: sparse:    unsigned long const __left
   lib/tests/fortify_kunit.c:1049:9: sparse:    bad type const __right
   lib/tests/fortify_kunit.c:1051:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
   lib/tests/fortify_kunit.c:1051:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
   lib/tests/fortify_kunit.c:1051:9: sparse: sparse: incompatible types for operation (==):
   lib/tests/fortify_kunit.c:1051:9: sparse:    unsigned long const __left
   lib/tests/fortify_kunit.c:1051:9: sparse:    bad type const __right
   lib/tests/fortify_kunit.c:1106:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
   lib/tests/fortify_kunit.c:1106:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
   lib/tests/fortify_kunit.c:1106:9: sparse: sparse: incompatible types for operation (==):
   lib/tests/fortify_kunit.c:1106:9: sparse:    unsigned long const __left
   lib/tests/fortify_kunit.c:1106:9: sparse:    bad type const __right
   lib/tests/fortify_kunit.c:1107:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
   lib/tests/fortify_kunit.c:1107:9: sparse: sparse: undefined identifier '__builtin_dynamic_object_size'
   lib/tests/fortify_kunit.c:1107:9: sparse: sparse: incompatible types for operation (==):
   lib/tests/fortify_kunit.c:1107:9: sparse:    unsigned long const __left
   lib/tests/fortify_kunit.c:1107:9: sparse:    bad type const __right

vim +1049 lib/tests/fortify_kunit.c

  1036	
  1037	static void fortify_test_counted_by_flex(struct kunit *test)
  1038	{
  1039		size_t size = 128;
  1040		struct counted_by_flex_struct *s;
  1041		size_t elem_bytes = size * sizeof(s->array[0]);
  1042	
  1043		s = alloc_counted_by_flex_struct(test, size);
  1044	
  1045		OPTIMIZER_HIDE_VAR(s);
  1046		OPTIMIZER_HIDE_VAR(elem_bytes);
  1047	
  1048		/* __builtin_dynamic_object_size() should return the logical length. */
> 1049		KUNIT_EXPECT_EQ(test, elem_bytes,
  1050				__builtin_dynamic_object_size(s->array, 0));
  1051		KUNIT_EXPECT_EQ(test, elem_bytes,
  1052				__builtin_dynamic_object_size(s->array, 1));
  1053	
  1054		/* Within-bounds write and read succeed. */
  1055		memset(s->array, 0x42, elem_bytes);
  1056		KUNIT_EXPECT_EQ(test, fortify_write_overflows, 0);
  1057		KUNIT_EXPECT_NOT_NULL(test, memchr(s->array, 0x42, elem_bytes));
  1058		KUNIT_EXPECT_EQ(test, fortify_read_overflows, 0);
  1059	
  1060		/* Out-of-bounds write and read past logical size are caught. */
  1061		memset(s->array, 0x42, elem_bytes + 1);
  1062		KUNIT_EXPECT_EQ(test, fortify_write_overflows, 1);
  1063		KUNIT_EXPECT_NULL(test, memchr(s->array, 0x42, elem_bytes + 1));
  1064		KUNIT_EXPECT_EQ(test, fortify_read_overflows, 1);
  1065	
  1066		kfree(s);
  1067	}
  1068	

--
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-09-30 15:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30 15:56 fortify: add KUnit tests for __counted_by and __counted_by_ptr 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.