From: kernel test robot <lkp@intel.com>
To: Kees Cook <kees@kernel.org>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [kees:dev/v7.0-rc2/strncpy 11/11] drivers/misc/lkdtm/fortify.c:28:9: warning: incompatible implicit declaration of built-in function 'strncpy'
Date: Tue, 24 Mar 2026 02:10:46 +0100 [thread overview]
Message-ID: <202603240259.tUb5PplF-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-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
reply other threads:[~2026-03-24 1:11 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=202603240259.tUb5PplF-lkp@intel.com \
--to=lkp@intel.com \
--cc=kees@kernel.org \
--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 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.