All of lore.kernel.org
 help / color / mirror / Atom feed
* [kees:dev/v7.0-rc2/strncpy 11/11] drivers/misc/lkdtm/fortify.c:28:9: warning: incompatible implicit declaration of built-in function 'strncpy'
@ 2026-03-24  1:10 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-03-24  1:10 UTC (permalink / raw)
  To: Kees Cook; +Cc: oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git dev/v7.0-rc2/strncpy
head:   da9b6bdc716b766da262998c114c86ebb1b96d43
commit: da9b6bdc716b766da262998c114c86ebb1b96d43 [11/11] string: Remove strncpy() from the kernel
config: x86_64-rhel-9.4-kselftests (https://download.01.org/0day-ci/archive/20260324/202603240259.tUb5PplF-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260324/202603240259.tUb5PplF-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/202603240259.tUb5PplF-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/misc/lkdtm/fortify.c: In function 'lkdtm_FORTIFY_STR_OBJECT':
   drivers/misc/lkdtm/fortify.c:28:9: error: implicit declaration of function 'strncpy' [-Wimplicit-function-declaration]
      28 |         strncpy(target[0].a, target[1].a, size);
         |         ^~~~~~~
   drivers/misc/lkdtm/fortify.c:10:1: note: include '<string.h>' or provide a declaration of 'strncpy'
       9 | #include <linux/slab.h>
     +++ |+#include <string.h>
      10 | 
>> drivers/misc/lkdtm/fortify.c:28:9: warning: incompatible implicit declaration of built-in function 'strncpy' [-Wbuiltin-declaration-mismatch]
      28 |         strncpy(target[0].a, target[1].a, size);
         |         ^~~~~~~
   drivers/misc/lkdtm/fortify.c:28:9: note: include '<string.h>' or provide a declaration of 'strncpy'
   drivers/misc/lkdtm/fortify.c: In function 'lkdtm_FORTIFY_STR_MEMBER':
   drivers/misc/lkdtm/fortify.c:60:9: warning: incompatible implicit declaration of built-in function 'strncpy' [-Wbuiltin-declaration-mismatch]
      60 |         strncpy(target.a, src, size);
         |         ^~~~~~~
   drivers/misc/lkdtm/fortify.c:60:9: note: include '<string.h>' or provide a declaration of 'strncpy'


vim +/strncpy +28 drivers/misc/lkdtm/fortify.c

fe8e353bfda6d6c Kees Cook 2021-08-18  12  
325bf6d84bad3fc Kees Cook 2022-08-31  13  static void lkdtm_FORTIFY_STR_OBJECT(void)
fe8e353bfda6d6c Kees Cook 2021-08-18  14  {
fe8e353bfda6d6c Kees Cook 2021-08-18  15  	struct target {
fe8e353bfda6d6c Kees Cook 2021-08-18  16  		char a[10];
325bf6d84bad3fc Kees Cook 2022-08-31  17  		int foo;
325bf6d84bad3fc Kees Cook 2022-08-31  18  	} target[3] = {};
fe8e353bfda6d6c Kees Cook 2021-08-18  19  	/*
fe8e353bfda6d6c Kees Cook 2021-08-18  20  	 * Using volatile prevents the compiler from determining the value of
fe8e353bfda6d6c Kees Cook 2021-08-18  21  	 * 'size' at compile time. Without that, we would get a compile error
fe8e353bfda6d6c Kees Cook 2021-08-18  22  	 * rather than a runtime error.
fe8e353bfda6d6c Kees Cook 2021-08-18  23  	 */
325bf6d84bad3fc Kees Cook 2022-08-31  24  	volatile int size = 20;
325bf6d84bad3fc Kees Cook 2022-08-31  25  
325bf6d84bad3fc Kees Cook 2022-08-31  26  	pr_info("trying to strcmp() past the end of a struct\n");
fe8e353bfda6d6c Kees Cook 2021-08-18  27  
325bf6d84bad3fc Kees Cook 2022-08-31 @28  	strncpy(target[0].a, target[1].a, size);
fe8e353bfda6d6c Kees Cook 2021-08-18  29  
fe8e353bfda6d6c Kees Cook 2021-08-18  30  	/* Store result to global to prevent the code from being eliminated */
325bf6d84bad3fc Kees Cook 2022-08-31  31  	fortify_scratch_space = target[0].a[3];
fe8e353bfda6d6c Kees Cook 2021-08-18  32  
325bf6d84bad3fc Kees Cook 2022-08-31  33  	pr_err("FAIL: fortify did not block a strncpy() object write overflow!\n");
fe8e353bfda6d6c Kees Cook 2021-08-18  34  	pr_expected_config(CONFIG_FORTIFY_SOURCE);
fe8e353bfda6d6c Kees Cook 2021-08-18  35  }
fe8e353bfda6d6c Kees Cook 2021-08-18  36  

:::::: The code at line 28 was first introduced by commit
:::::: 325bf6d84bad3fc641b94fad6e69c70e960fdf2e lkdtm: Update tests for memcpy() run-time warnings

:::::: 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] only message in thread

only message in thread, other threads:[~2026-03-24  1:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24  1:10 [kees:dev/v7.0-rc2/strncpy 11/11] drivers/misc/lkdtm/fortify.c:28:9: warning: incompatible implicit declaration of built-in function 'strncpy' 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.