On Mon, Mar 16, 2026 at 04:17:28PM +0000, Josh Law wrote:
> BUG_ON() in a library function is too harsh -- it panics the kernel
> when a caller passes a dest string whose length already meets or
> exceeds count. This is a caller bug, not a reason to bring down the
> entire system.
> 
> Replace with WARN_ON_ONCE() and a safe early return. The return value
> of count signals truncation to the caller, consistent with strlcat
> semantics (return >= count means the output was truncated).
> 
> This follows the guidance in include/asm-generic/bug.h which
> explicitly discourages BUG_ON: "Don't use BUG() or BUG_ON() unless
> there's really no way out."

First of all, this doesn't really change much, especially if one uses
panic_on_oops.

Second, the entire function is kinda deprecated, it's better just to drop it.

$ git grep -lw strlcat | wc -l
142

(In reality it's less as tools and implementation are not users of it)

Third, if the caller is that problematic this may lead to the serious
(security) issues.

Based on that, NAK.

-- 
With Best Regards,
Andy Shevchenko



Reply via email to