On Tue, Mar 24, 2026 at 1:26 PM Kees Cook <[email protected]> wrote: > > 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 IMHO, it's a flaky test failure, likely caused by timer-related activity when selftests/bpf are running concurrently.
As for your patch, replacing strncpy() makes sense, but this also changes semantics for overlong map names: they are silently truncated to 15 bytes. I'd prefer an explicit length check and rejecting the overlong names, instead of normalizing them by truncation. Sun Jian

