public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] lib/vsprintf: Fixes size check
@ 2026-03-21 14:41 Masami Hiramatsu (Google)
  2026-03-21 14:41 ` [PATCH v3 1/2] lib/vsprintf: Fix to check field_width and precision Masami Hiramatsu (Google)
  2026-03-21 14:41 ` [PATCH v3 2/2] lib/vsprintf: Limit the returning size to INT_MAX Masami Hiramatsu (Google)
  0 siblings, 2 replies; 12+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-03-21 14:41 UTC (permalink / raw)
  To: Petr Mladek, Steven Rostedt, Andy Shevchenko
  Cc: Rasmus Villemoes, Sergey Senozhatsky, Andrew Morton, David Laight,
	linux-kernel

Hi,

Here is the 3rd version of patches to fix vsnprintf().

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

Previous version is here;

https://lore.kernel.org/all/177397887883.33018.9867883986177366222.stgit@devnote2/

In this version, check and update witdth and precision before assigning to spec
data structure [1/2] and use a local variable to be better readability [2/2].

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 |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

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

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

end of thread, other threads:[~2026-03-25  9:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 14:41 [PATCH v3 0/2] lib/vsprintf: Fixes size check Masami Hiramatsu (Google)
2026-03-21 14:41 ` [PATCH v3 1/2] lib/vsprintf: Fix to check field_width and precision Masami Hiramatsu (Google)
2026-03-23 13:27   ` Andy Shevchenko
2026-03-23 13:59     ` David Laight
2026-03-24 16:45       ` Petr Mladek
2026-03-24 17:24         ` David Laight
2026-03-25  0:33           ` Masami Hiramatsu
2026-03-25  1:17             ` Masami Hiramatsu
2026-03-25  9:14               ` David Laight
2026-03-25  0:26     ` Masami Hiramatsu
2026-03-21 14:41 ` [PATCH v3 2/2] lib/vsprintf: Limit the returning size to INT_MAX Masami Hiramatsu (Google)
2026-03-24 16:50   ` Petr Mladek

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