Re: [PATCH] libbpf: Replace strncpy() with strnlen()+memcpy() in skel_map_create()

From: Kees Cook

Date: Tue Mar 24 2026 - 01:26:11 EST


On Mon, Mar 23, 2026 at 09:05:39PM -0700, Kees Cook wrote:
> While the original strncpy() would have copied a full 16 bytes from an
> overlong name (producing an unterminated field that the syscall rejects),
> but this wasn't a reachable state. This replacement will instead always
> truncate to 15 bytes and keeps the NUL terminator, which should have no
> behavioral changes with the present code and avoids potential issues
> with future over-long string literals.

Hm, I got a failure report, but it *seems* unrelated? But nothing else
fails that way recently, so I will try a v2 with the "unterminated at 16
bytes" behavior restored and see if it passes...

test_progs_no_alu32-x86_64-llvm-21:
https://github.com/kernel-patches/bpf/actions/runs/23472955268/job/68300440546


--
Kees Cook