Re: [PATCH v3] libbpf: harden parse_vma_segs() path parsing

From: Michael Bommarito

Date: Fri May 22 2026 - 14:13:08 EST


On Fri, May 22, 2026 at 1:58 PM Emil Tsalapatis <emil@xxxxxxxxxxxxxxx> wrote:
> Minor nit in case this gets respun: Can you mention that the n >= int(sizeof(line)) check also
> takes care of making sure the libbpf_strlcpy below doesn't overflow path?

Sure, will make a note.

> It would be nice if we could somehow not hardcode the lengths to make it clear,
> where we're deriving the values from, but unless I'm missing something there
> the only way would be to snprintf the format string every single time which would
> be overkill.

My first draft patch (Claude's, really) did that but it had an ugly
inner loop and like you said, possibly introduced more ways to make a
mistake. I think there is a real pedantic version that could be
written more elegantly with helper macros/functions that could be
shared across other sites, but maybe that belongs in a separate follow
up.

Thanks,
Mike