Re: [PATCH] media: radio: Replace strlcat() with seq_buf in TEA drivers
From: Kees Cook
Date: Thu Nov 12 2026 - 17:19:08 EST
On Thu, Nov 12, 2026 at 07:07:02PM +0000, David Laight wrote:
> But both snprintf() and seq_buf are far more expensive than doing the
> strlen().
> There is the separate issue that strlcpy() manages to needlessly inline a
> strnlen() in a lot of the call sites - instead of deferring it to the
> helper function.
Right, my driving goal here isn't about performance, it's about
correctness (as much as possible given our giant codebase). We don't
need the most perfect fast implementation if it's too easy to shoot our
feet. strlcat() requires an external bounds that has no strict tie to
the destination argument, and it has no bounds information at all for
the source argument.
If we're in fast-path, we have a different set of criteria. And seq_buf
was actually designed for that, as it trades storage for speed: it keeps
the needed offsets in memory, but that makes it fast for stuff like
perf.
--
Kees Cook