public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] lib/vsprintf: Fixes size check
@ 2026-03-20  3:52 Masami Hiramatsu (Google)
  2026-03-20  3:56 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-03-20  3:52 UTC (permalink / raw)
  To: Petr Mladek, Steven Rostedt, Andy Shevchenko
  Cc: Rasmus Villemoes, Sergey Senozhatsky, Andrew Morton, David Laight,
	linux-kernel

Hi,

Here is a pair of patches to fix vsnprintf().

 - Fix to limit the size of width and precision.
 - Warn if the return size is over INT_MAX.

Recently we discussed snprintf() usage in bootconfig and found snprintf()
design has a problem[1]. It returns the required or printed size in 'int'
but the maxlen is passed by 'size_t'. The maxlen is already limited by
INT_MAX, but if the expected print size becomes bigger than INT_MAX,
it can return negative value. We also found width and precision size check
does not work.

[1] https://lore.kernel.org/all/20260317121507.30735331@gandalf.local.home/

Thank you,

---

Masami Hiramatsu (Google) (2):
      lib/vsprintf: Fix to check field_width and precision
      lib/vsprintf: Limit the returning size to INT_MAX


 lib/vsprintf.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 0/1] lib/vsprintf: Fixes size check
  2026-03-20  3:52 [PATCH 0/1] lib/vsprintf: Fixes size check Masami Hiramatsu (Google)
@ 2026-03-20  3:56 ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2026-03-20  3:56 UTC (permalink / raw)
  To: Masami Hiramatsu (Google)
  Cc: Petr Mladek, Steven Rostedt, Andy Shevchenko, Rasmus Villemoes,
	Sergey Senozhatsky, Andrew Morton, David Laight, linux-kernel

Sorry, I made a mistake on sending series. See v2.

On Fri, 20 Mar 2026 12:52:14 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> Hi,
> 
> Here is a pair of patches to fix vsnprintf().
> 
>  - Fix to limit the size of width and precision.
>  - Warn if the return size is over INT_MAX.
> 
> Recently we discussed snprintf() usage in bootconfig and found snprintf()
> design has a problem[1]. It returns the required or printed size in 'int'
> but the maxlen is passed by 'size_t'. The maxlen is already limited by
> INT_MAX, but if the expected print size becomes bigger than INT_MAX,
> it can return negative value. We also found width and precision size check
> does not work.
> 
> [1] https://lore.kernel.org/all/20260317121507.30735331@gandalf.local.home/
> 
> Thank you,
> 
> ---
> 
> Masami Hiramatsu (Google) (2):
>       lib/vsprintf: Fix to check field_width and precision
>       lib/vsprintf: Limit the returning size to INT_MAX
> 
> 
>  lib/vsprintf.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-20  3:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20  3:52 [PATCH 0/1] lib/vsprintf: Fixes size check Masami Hiramatsu (Google)
2026-03-20  3:56 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox