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>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/vsprintf: Fix to check field_width and precision
Date: Fri, 20 Mar 2026 11:20:55 +0900 [thread overview]
Message-ID: <20260320112055.ddac4b158bb84b2d2a76fe00@kernel.org> (raw)
In-Reply-To: <abuhmX31mGRtkDkh@ashevche-desk.local>
On Thu, 19 Mar 2026 09:11:21 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Thu, Mar 19, 2026 at 09:26:59AM +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.
>
> ...
>
> > spec->field_width = width;
> > - if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) {
> > + if (WARN_ONCE(spec->field_width > FIELD_WIDTH_MAX ||
> > + spec->field_width < -FIELD_WIDTH_MAX, "field width %d too large", width)) {
>
> Also use logical split as below:
>
> if (WARN_ONCE(spec->field_width > FIELD_WIDTH_MAX || spec->field_width < -FIELD_WIDTH_MAX,
> "field width %d too large", width)) {
OK, let me update it.
Thanks,
>
> > spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX);
> > }
> > }
>
> ...
>
> > spec->precision = prec;
> > - if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) {
> > + if (WARN_ONCE(spec->precision > PRECISION_MAX || spec->precision < 0,
> > + "precision %d too large", prec)) {
> > spec->precision = clamp(prec, 0, PRECISION_MAX);
> > }
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2026-03-20 2:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 0:26 [PATCH] lib/vsprintf: Fix to check field_width and precision Masami Hiramatsu (Google)
2026-03-19 7:11 ` Andy Shevchenko
2026-03-20 2:20 ` Masami Hiramatsu [this message]
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=20260320112055.ddac4b158bb84b2d2a76fe00@kernel.org \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox