Skip to contentSkip to conversation

bpf: Replace deprecated strcpy() with strscpy()

PATCH Superseded Thorsten Blum 2 participants 2 messages Jul 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Replace deprecated strcpy() with strscpy()

strcpy() is deprecated; use strscpy() instead.

No functional changes intended.

---
 kernel/bpf/disasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/disasm.c +1 -1
index 20883c6b1546..c8f657237e97 100644
@@ -349,7 +349,7 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
 					__func_get_name(cbs, insn,
 							tmp, sizeof(tmp)));
 			} else {
-				strcpy(tmp, "unknown");
+				strscpy(tmp, "unknown");
 				verbose(cbs->private_data, "(%02x) call %s#%d\n", insn->code,
 					__func_get_name(cbs, insn,
 							tmp, sizeof(tmp)),
Signature · 1 line
2.50.0
maintainer
#1 lore raw

2025-07-14 20:23 UTC+0200 ~ Thorsten Blum <[email protected]>

Quoted 8 lines

strcpy() is deprecated; use strscpy() instead.

No functional changes intended.

---
 kernel/bpf/disasm.c | 2 +-

Hi and thank you for the patch,

The disassembler file is also part of bpftool's source code [0][1], where it is compiled as user space code, and where strscpy() is not defined. So I'd rather not replace this particular occurrence of strcpy(). We could add a comment in the file to mention this, though.

Thanks,
Quentin

[0]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/bpf/bpftool/Makefile#n246
[1]:
https://github.com/libbpf/bpftool/blob/v7.5.0/src/kernel/bpf/disasm.c#L340