From: sashiko-bot@kernel.org
To: "Kees Cook" <kees@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v5] libbpf: Use strscpy() in kernel code for skel_map_create()
Date: Thu, 14 May 2026 01:56:09 +0000 [thread overview]
Message-ID: <20260514015610.1D339C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260513050806.do.620-kees@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The use of the 2-argument `strscpy` macro in `skel_internal.h` breaks compilation of light skeletons for out-of-tree kernel modules on kernels older than 6.8.
--
commit 056f88b29a55562ae428a73e0cbb771aa82987a6
Author: Kees Cook <kees@kernel.org>
libbpf: Use strscpy() in kernel code for skel_map_create()
This commit replaces a deprecated strncpy() call with strscpy() in
skel_map_create() when building for the kernel, leaving the user-space
version unchanged.
Link: https://github.com/KSPP/linux/issues/90 [1]
> diff --git a/tools/lib/bpf/skel_internal.h b/tools/lib/bpf/skel_internal.h
> --- a/tools/lib/bpf/skel_internal.h
> +++ b/tools/lib/bpf/skel_internal.h
[ ... ]
> @@ -243,7 +243,12 @@ static inline int skel_map_create(enum bpf_map_type map_type,
> attr.excl_prog_hash = (unsigned long) excl_prog_hash;
> attr.excl_prog_hash_size = excl_prog_hash_sz;
>
> +#ifdef __KERNEL__
> + if (strscpy(attr.map_name, map_name) < 0)
Does this break backwards compatibility for out-of-tree kernel modules using
generated light skeletons on kernels older than 6.8?
The 2-argument strscpy macro was introduced in Linux 6.8. Older kernels like
6.1 LTS and 6.6 LTS only provide the 3-argument version:
ssize_t strscpy(char *dest, const char *src, size_t count).
Compiling this generated skeleton code on older kernels will result in a
compiler error due to too few arguments.
Would it be better to use the 3-argument version here instead?
strscpy(attr.map_name, map_name, sizeof(attr.map_name))
> + return -EINVAL;
> +#else
> strncpy(attr.map_name, map_name, sizeof(attr.map_name));
> +#endif
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260513050806.do.620-kees@kernel.org?part=1
next prev parent reply other threads:[~2026-05-14 1:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 5:08 [PATCH v5] libbpf: Use strscpy() in kernel code for skel_map_create() Kees Cook
2026-05-13 18:03 ` patchwork-bot+netdevbpf
2026-05-14 1:56 ` sashiko-bot [this message]
2026-05-14 3:20 ` Kees Cook
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=20260514015610.1D339C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kees@kernel.org \
--cc=sashiko-reviews@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