All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Laight <david.laight.linux@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 1/2] lib/vsprintf: Fix to check field_width and precision
Date: Thu, 26 Mar 2026 20:57:58 +0900	[thread overview]
Message-ID: <20260326205758.d2dd498a0cada73953cf68d7@kernel.org> (raw)
In-Reply-To: <acUDGi9Tetud4XQ7@ashevche-desk.local>

On Thu, 26 Mar 2026 11:57:46 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Wed, Mar 25, 2026 at 10:27:41PM +0900, Masami Hiramatsu (Google) wrote:
> 
> > Check the field_width and presition correctly. Previously it depends
> > on the bitfield conversion from int to check out-of-range error.
> > However, commit 938df695e98d ("vsprintf: associate the format state
> > with the format pointer") changed those fields to int.
> > We need to check the out-of-range correctly without bitfield
> > conversion.
> 
> ...
> 
> > +static void
> > +set_field_width(struct printf_spec *spec, int width)
> 
> One line.
> 

Ah, OK.

> static void set_field_width(struct printf_spec *spec, int width)
> 
> > +{
> > +	spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX);
> > +	WARN_ONCE(spec->field_width != width, "field width %d out of range",
> > +		  width);
> 
> I would also make it one line for readability.
> 
> 	WARN_ONCE(spec->field_width != width, "field width %d out of range", width);

OK.

> 
> > +}
> > +
> > +static void
> > +set_precision(struct printf_spec *spec, int prec)
> 
> One line
> 
> static void set_precision(struct printf_spec *spec, int prec)

OK, let me update it.

Thanks for review!

> 
> > +{
> > +	spec->precision = clamp(prec, 0, PRECISION_MAX);
> > +	WARN_ONCE(spec->precision < prec, "precision %d too large", prec);
> > +}
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 


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

  reply	other threads:[~2026-03-26 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 13:27 [PATCH v5 0/2] lib/vsprintf: Fixes size check Masami Hiramatsu (Google)
2026-03-25 13:27 ` [PATCH v5 1/2] lib/vsprintf: Fix to check field_width and precision Masami Hiramatsu (Google)
2026-03-26  9:57   ` Andy Shevchenko
2026-03-26 11:57     ` Masami Hiramatsu [this message]
2026-03-25 13:27 ` [PATCH v5 2/2] lib/vsprintf: Limit the returning size to INT_MAX Masami Hiramatsu (Google)
2026-03-25 13:41 ` [PATCH v5 0/2] lib/vsprintf: Fixes size check Masami Hiramatsu
2026-03-26  9:54   ` Andy Shevchenko
2026-03-26 11:51     ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260326205758.d2dd498a0cada73953cf68d7@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.