public inbox for oe-kbuild@lists.linux.dev
 help / color / mirror / Atom feed
* lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208
@ 2025-05-25  6:12 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-05-25  6:12 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Julia Lawall

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Kees Cook <kees@kernel.org>
CC: David Gow <davidgow@google.com>
CC: Rae Moar <rmoar@google.com>

Hi Kees,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b1427432d3b656fac71b3f42824ff4aea3c9f93b
commit: db6fe4d61ece24193eb4d94a82d967501d53358c lib: Move KUnit tests into tests/ subdirectory
date:   3 months ago
:::::: branch date: 14 hours ago
:::::: commit date: 3 months ago
config: x86_64-randconfig-104-20250525 (https://download.01.org/0day-ci/archive/20250525/202505251407.2K2POdSl-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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/202505251407.2K2POdSl-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208
   lib/tests/fortify_kunit.c:213:8-9: ERROR: reference preceded by free on line 211
   lib/tests/fortify_kunit.c:216:8-9: ERROR: reference preceded by free on line 213
   lib/tests/fortify_kunit.c:218:8-9: ERROR: reference preceded by free on line 216
   lib/tests/fortify_kunit.c:220:8-9: ERROR: reference preceded by free on line 218
   lib/tests/fortify_kunit.c:223:8-9: ERROR: reference preceded by free on line 220
   lib/tests/fortify_kunit.c:226:8-9: ERROR: reference preceded by free on line 223
   lib/tests/fortify_kunit.c:228:8-9: ERROR: reference preceded by free on line 226
   lib/tests/fortify_kunit.c:230:8-9: ERROR: reference preceded by free on line 228
   lib/tests/fortify_kunit.c:233:8-9: ERROR: reference preceded by free on line 230
   lib/tests/fortify_kunit.c:236:8-9: ERROR: reference preceded by free on line 233
   lib/tests/fortify_kunit.c:242:8-9: ERROR: reference preceded by free on line 236
   lib/tests/fortify_kunit.c:247:8-9: ERROR: reference preceded by free on line 242
   lib/tests/fortify_kunit.c:252:8-9: ERROR: reference preceded by free on line 247
   lib/tests/fortify_kunit.c:258:54-55: ERROR: reference preceded by free on line 252
   lib/tests/fortify_kunit.c:377:9-10: ERROR: reference preceded by free on line 375
   lib/tests/fortify_kunit.c:375:9-10: ERROR: reference preceded by free on line 377

vim +211 lib/tests/fortify_kunit.c

9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  201  
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  202  #define TEST_kmalloc(checker, expected_size, alloc_size)	do {	\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  203  	gfp_t gfp = GFP_KERNEL | __GFP_NOWARN;				\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  204  	void *orig;							\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  205  	size_t len;							\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  206  									\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  207  	checker(expected_size, kmalloc(alloc_size, gfp),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29 @208  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  209  	checker(expected_size,						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  210  		kmalloc_node(alloc_size, gfp, NUMA_NO_NODE),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29 @211  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  212  	checker(expected_size, kzalloc(alloc_size, gfp),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  213  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  214  	checker(expected_size,						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  215  		kzalloc_node(alloc_size, gfp, NUMA_NO_NODE),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  216  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  217  	checker(expected_size, kcalloc(1, alloc_size, gfp),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  218  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  219  	checker(expected_size, kcalloc(alloc_size, 1, gfp),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  220  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  221  	checker(expected_size,						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  222  		kcalloc_node(1, alloc_size, gfp, NUMA_NO_NODE),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  223  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  224  	checker(expected_size,						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  225  		kcalloc_node(alloc_size, 1, gfp, NUMA_NO_NODE),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  226  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  227  	checker(expected_size, kmalloc_array(1, alloc_size, gfp),	\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  228  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  229  	checker(expected_size, kmalloc_array(alloc_size, 1, gfp),	\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  230  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  231  	checker(expected_size,						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  232  		kmalloc_array_node(1, alloc_size, gfp, NUMA_NO_NODE),	\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  233  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  234  	checker(expected_size,						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  235  		kmalloc_array_node(alloc_size, 1, gfp, NUMA_NO_NODE),	\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  236  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  237  									\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  238  	orig = kmalloc(alloc_size, gfp);				\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  239  	KUNIT_EXPECT_TRUE(test, orig != NULL);				\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  240  	checker((expected_size) * 2,					\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  241  		krealloc(orig, (alloc_size) * 2, gfp),			\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  242  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  243  	orig = kmalloc(alloc_size, gfp);				\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  244  	KUNIT_EXPECT_TRUE(test, orig != NULL);				\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  245  	checker((expected_size) * 2,					\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  246  		krealloc_array(orig, 1, (alloc_size) * 2, gfp),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  247  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  248  	orig = kmalloc(alloc_size, gfp);				\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  249  	KUNIT_EXPECT_TRUE(test, orig != NULL);				\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  250  	checker((expected_size) * 2,					\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  251  		krealloc_array(orig, (alloc_size) * 2, 1, gfp),		\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  252  		kfree(p));						\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  253  									\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  254  	len = 11;							\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  255  	/* Using memdup() with fixed size, so force unknown length. */	\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  256  	if (!__builtin_constant_p(expected_size))			\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  257  		len += zero_size;					\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  258  	checker(len, kmemdup("hello there", len, gfp), kfree(p));	\
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  259  } while (0)
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  260  DEFINE_ALLOC_SIZE_TEST_PAIR(kmalloc)
9124a26401483bf lib/fortify_kunit.c Kees Cook 2022-09-29  261  

:::::: The code at line 211 was first introduced by commit
:::::: 9124a26401483bf2b13a99cb4317dce3f677060f kunit/fortify: Validate __alloc_size attribute results

:::::: TO: Kees Cook <keescook@chromium.org>
:::::: CC: Kees Cook <keescook@chromium.org>

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

^ permalink raw reply	[flat|nested] 2+ messages in thread
* lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208
@ 2026-03-30 12:18 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-03-30 12:18 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Julia Lawall

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Kees Cook <kees@kernel.org>
CC: David Gow <davidgow@google.com>
CC: Rae Moar <rmoar@google.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   7aaa8047eafd0bd628065b15757d9b48c5f9c07d
commit: db6fe4d61ece24193eb4d94a82d967501d53358c lib: Move KUnit tests into tests/ subdirectory
date:   1 year, 2 months ago
:::::: branch date: 14 hours ago
:::::: commit date: 1 year, 2 months ago
config: powerpc64-randconfig-r052-20260330 (https://download.01.org/0day-ci/archive/20260330/202603302040.VStJOW2P-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 054e11d1a17e5ba88bb1a8ef32fad3346e80b186)

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/202603302040.VStJOW2P-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208
   lib/tests/fortify_kunit.c:213:8-9: ERROR: reference preceded by free on line 211
   lib/tests/fortify_kunit.c:216:8-9: ERROR: reference preceded by free on line 213
   lib/tests/fortify_kunit.c:218:8-9: ERROR: reference preceded by free on line 216
   lib/tests/fortify_kunit.c:220:8-9: ERROR: reference preceded by free on line 218
   lib/tests/fortify_kunit.c:223:8-9: ERROR: reference preceded by free on line 220
   lib/tests/fortify_kunit.c:226:8-9: ERROR: reference preceded by free on line 223
   lib/tests/fortify_kunit.c:228:8-9: ERROR: reference preceded by free on line 226
   lib/tests/fortify_kunit.c:230:8-9: ERROR: reference preceded by free on line 228
   lib/tests/fortify_kunit.c:233:8-9: ERROR: reference preceded by free on line 230
   lib/tests/fortify_kunit.c:236:8-9: ERROR: reference preceded by free on line 233
   lib/tests/fortify_kunit.c:242:8-9: ERROR: reference preceded by free on line 236
   lib/tests/fortify_kunit.c:247:8-9: ERROR: reference preceded by free on line 242
   lib/tests/fortify_kunit.c:252:8-9: ERROR: reference preceded by free on line 247
   lib/tests/fortify_kunit.c:258:54-55: ERROR: reference preceded by free on line 252
   lib/tests/fortify_kunit.c:377:9-10: ERROR: reference preceded by free on line 375
   lib/tests/fortify_kunit.c:375:9-10: ERROR: reference preceded by free on line 377

vim +211 lib/tests/fortify_kunit.c

9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  201  
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  202  #define TEST_kmalloc(checker, expected_size, alloc_size)	do {	\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  203  	gfp_t gfp = GFP_KERNEL | __GFP_NOWARN;				\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  204  	void *orig;							\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  205  	size_t len;							\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  206  									\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  207  	checker(expected_size, kmalloc(alloc_size, gfp),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 @208  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  209  	checker(expected_size,						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  210  		kmalloc_node(alloc_size, gfp, NUMA_NO_NODE),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 @211  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  212  	checker(expected_size, kzalloc(alloc_size, gfp),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  213  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  214  	checker(expected_size,						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  215  		kzalloc_node(alloc_size, gfp, NUMA_NO_NODE),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  216  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  217  	checker(expected_size, kcalloc(1, alloc_size, gfp),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  218  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  219  	checker(expected_size, kcalloc(alloc_size, 1, gfp),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  220  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  221  	checker(expected_size,						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  222  		kcalloc_node(1, alloc_size, gfp, NUMA_NO_NODE),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  223  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  224  	checker(expected_size,						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  225  		kcalloc_node(alloc_size, 1, gfp, NUMA_NO_NODE),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  226  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  227  	checker(expected_size, kmalloc_array(1, alloc_size, gfp),	\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  228  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  229  	checker(expected_size, kmalloc_array(alloc_size, 1, gfp),	\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  230  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  231  	checker(expected_size,						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  232  		kmalloc_array_node(1, alloc_size, gfp, NUMA_NO_NODE),	\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  233  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  234  	checker(expected_size,						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  235  		kmalloc_array_node(alloc_size, 1, gfp, NUMA_NO_NODE),	\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  236  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  237  									\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  238  	orig = kmalloc(alloc_size, gfp);				\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  239  	KUNIT_EXPECT_TRUE(test, orig != NULL);				\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  240  	checker((expected_size) * 2,					\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  241  		krealloc(orig, (alloc_size) * 2, gfp),			\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  242  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  243  	orig = kmalloc(alloc_size, gfp);				\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  244  	KUNIT_EXPECT_TRUE(test, orig != NULL);				\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  245  	checker((expected_size) * 2,					\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  246  		krealloc_array(orig, 1, (alloc_size) * 2, gfp),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  247  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  248  	orig = kmalloc(alloc_size, gfp);				\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  249  	KUNIT_EXPECT_TRUE(test, orig != NULL);				\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  250  	checker((expected_size) * 2,					\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  251  		krealloc_array(orig, (alloc_size) * 2, 1, gfp),		\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  252  		kfree(p));						\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  253  									\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  254  	len = 11;							\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  255  	/* Using memdup() with fixed size, so force unknown length. */	\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  256  	if (!__builtin_constant_p(expected_size))			\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  257  		len += zero_size;					\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  258  	checker(len, kmemdup("hello there", len, gfp), kfree(p));	\
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  259  } while (0)
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  260  DEFINE_ALLOC_SIZE_TEST_PAIR(kmalloc)
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29  261  

:::::: The code at line 211 was first introduced by commit
:::::: 9124a26401483bf2b13a99cb4317dce3f677060f kunit/fortify: Validate __alloc_size attribute results

:::::: TO: Kees Cook <keescook@chromium.org>
:::::: CC: Kees Cook <keescook@chromium.org>

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-30 12:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25  6:12 lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208 kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-30 12:18 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox