Re: Coverity: console_prepend_dropped(): Memory - corruptions

From: Sergey Senozhatsky
Date: Mon Jan 16 2023 - 22:08:07 EST


On (23/01/16 17:35), Petr Mladek wrote:
>
> I am going to send a patch.

Sure, sounds good.

> The code might be safe with the current size of the buffer and
> the string. But it is true that the following is wrong:
>
> len = snprintf(scratchbuf, scratchbuf_sz,
> "** %lu printk messages dropped **\n", dropped);

Wouldn't

if (WARN_ON_ONCE(len + PRINTK_PREFIX_MAX >= outbuf_sz))
return;

prevent us from doing something harmful?