public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Kees Cook <kees@kernel.org>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: [kees:dev/v7.0-rc2/strncpy 11/11] drivers/misc/lkdtm/fortify.c:28:2: error: call to undeclared library function 'strncpy' with type 'char *(char *, const char *, unsigned long)'; ISO C99 and later do not support implicit function declarations
Date: Tue, 24 Mar 2026 10:24:42 +0800	[thread overview]
Message-ID: <202603241035.G4pY8cMm-lkp@intel.com> (raw)

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-buildonly-randconfig-006-20260324 (https://download.01.org/0day-ci/archive/20260324/202603241035.G4pY8cMm-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260324/202603241035.G4pY8cMm-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/202603241035.G4pY8cMm-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/misc/lkdtm/fortify.c:28:2: error: call to undeclared library function 'strncpy' with type 'char *(char *, const char *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      28 |         strncpy(target[0].a, target[1].a, size);
         |         ^
   drivers/misc/lkdtm/fortify.c:28:2: note: include the header <string.h> or explicitly provide a declaration for 'strncpy'
   1 error generated.


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

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

                 reply	other threads:[~2026-03-24  2:25 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=202603241035.G4pY8cMm-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kees@kernel.org \
    --cc=llvm@lists.linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox