* [PATCH bpf-next v2] bpf: Replace snprintf("%s", ...) with strscpy in parse_{base,module}
@ 2026-02-01 21:52 Thorsten Blum
2026-02-03 2:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-02-01 21:52 UTC (permalink / raw)
To: Martin KaFai Lau, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
Cc: Thorsten Blum, bpf, linux-kernel
Replace snprintf("%s", ...) with the faster and more direct strscpy().
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Keep snprintf("%s", ...) in btf_show_name() as suggested by Alexei
- Update patch title
- Link to v1: https://lore.kernel.org/lkml/20260201180445.664056-2-thorsten.blum@linux.dev/
---
kernel/bpf/btf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 8959f3bc1e92..7708958e3fb8 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -25,6 +25,7 @@
#include <linux/perf_event.h>
#include <linux/bsearch.h>
#include <linux/kobject.h>
+#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/overflow.h>
@@ -6324,7 +6325,7 @@ static struct btf *btf_parse_base(struct btf_verifier_env *env, const char *name
btf->data_size = data_size;
btf->kernel_btf = true;
btf->named_start_id = 0;
- snprintf(btf->name, sizeof(btf->name), "%s", name);
+ strscpy(btf->name, name);
err = btf_parse_hdr(env);
if (err)
@@ -6443,7 +6444,7 @@ static struct btf *btf_parse_module(const char *module_name, const void *data,
btf->start_str_off = base_btf->hdr.str_len;
btf->kernel_btf = true;
btf->named_start_id = 0;
- snprintf(btf->name, sizeof(btf->name), "%s", module_name);
+ strscpy(btf->name, module_name);
btf->data = kvmemdup(data, data_size, GFP_KERNEL | __GFP_NOWARN);
if (!btf->data) {
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH bpf-next v2] bpf: Replace snprintf("%s", ...) with strscpy in parse_{base,module}
2026-02-01 21:52 [PATCH bpf-next v2] bpf: Replace snprintf("%s", ...) with strscpy in parse_{base,module} Thorsten Blum
@ 2026-02-03 2:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-03 2:50 UTC (permalink / raw)
To: Thorsten Blum
Cc: martin.lau, ast, daniel, andrii, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Sun, 1 Feb 2026 22:52:48 +0100 you wrote:
> Replace snprintf("%s", ...) with the faster and more direct strscpy().
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> Changes in v2:
> - Keep snprintf("%s", ...) in btf_show_name() as suggested by Alexei
> - Update patch title
> - Link to v1: https://lore.kernel.org/lkml/20260201180445.664056-2-thorsten.blum@linux.dev/
>
> [...]
Here is the summary with links:
- [bpf-next,v2] bpf: Replace snprintf("%s", ...) with strscpy in parse_{base,module}
https://git.kernel.org/bpf/bpf-next/c/d95d76aa772b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-03 2:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-01 21:52 [PATCH bpf-next v2] bpf: Replace snprintf("%s", ...) with strscpy in parse_{base,module} Thorsten Blum
2026-02-03 2:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox