From: Josh Law <objecting@objecting.org>
To: <pmladek@suse.com>
Cc: <rostedt@goodmis.org>, <andriy.shevchenko@linux.intel.com>,
<linux@rasmusvillemoes.dk>, <senozhatsky@chromium.org>,
<akpm@linux-foundation.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/4] lib/vsprintf: add missing (u8) cast in format_decode() lookup
Date: Tue, 31 Mar 2026 15:44:23 +0100 [thread overview]
Message-ID: <19d445a54ed.6d9a96e398729.3161855776737149670@objecting.org> (raw)
In-Reply-To: <acvbUaYz7sPY8MPS@pathway.suse.cz>
---- On Tue, 31 Mar 2026 15:33:53 +0100 pmladek@suse.com wrote ----
> On Tue 2026-03-24 22:49:40, Josh Law wrote:
> > The first lookup into the format_state table correctly casts to (u8)
> > at line 2778, but the second lookup after consuming a length qualifier
> > does not. On signed-char platforms, a byte >= 0x80 sign-extends to a
> > negative index, reading before the array.
> >
> > Add the same (u8) cast for consistency.
> >
> > Signed-off-by: Josh Law
>
> > ---
> > lib/vsprintf.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> > index 2758096b6f53..3108823e8c22 100644
> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -2783,7 +2783,7 @@ struct fmt format_decode(struct fmt fmt, struct
> printf_spec *spec)
> > fmt.str++;
> > }
> > fmt.str++;
> > - p = lookup_state + *fmt.str;
> > + p = lookup_state + (u8)*fmt.str;
> > }
> > if (p->state) {
> > if (p->base)
>
> This makes sense. Even though the current code is safe as pointed
> out by Andy.
>
> Reviewed-by: Petr Mladek
>
> Best Regards,
> Petr
Yeah, better safe than sorry in my opinion.
Thanks for the review petr!
next prev parent reply other threads:[~2026-03-31 14:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 22:49 [PATCH 0/4] lib/vsprintf: assorted bug fixes Josh Law
2026-03-24 22:49 ` [PATCH 1/4] lib/vsprintf: always advance args in bstr_printf() pointer path Josh Law
2026-03-30 16:06 ` Petr Mladek
2026-03-24 22:49 ` [PATCH 2/4] lib/vsprintf: fix OOB write in vbin_printf() when size is zero Josh Law
2026-03-30 16:17 ` Petr Mladek
2026-03-30 16:31 ` Steven Rostedt
2026-03-30 16:32 ` Josh Law
2026-03-30 16:32 ` Josh Law
2026-03-30 16:32 ` Josh Law
2026-03-30 16:34 ` Josh Law
2026-03-24 22:49 ` [PATCH 3/4] lib/vsprintf: use int for field_width in vsscanf() Josh Law
2026-03-25 12:00 ` Andy Shevchenko
2026-03-31 14:31 ` Petr Mladek
2026-03-31 15:35 ` David Laight
2026-03-31 16:12 ` Petr Mladek
2026-03-31 16:13 ` Josh Law
2026-03-31 16:13 ` Josh Law
2026-03-31 16:13 ` Josh Law
2026-04-01 14:22 ` David Laight
2026-04-01 18:29 ` David Laight
2026-03-24 22:49 ` [PATCH 4/4] lib/vsprintf: add missing (u8) cast in format_decode() lookup Josh Law
2026-03-25 12:02 ` Andy Shevchenko
2026-03-31 14:33 ` Petr Mladek
2026-03-31 14:44 ` Josh Law [this message]
2026-03-31 14:44 ` Josh Law
2026-03-25 12:05 ` [PATCH 0/4] lib/vsprintf: assorted bug fixes Andy Shevchenko
2026-03-25 17:20 ` Josh Law
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=19d445a54ed.6d9a96e398729.3161855776737149670@objecting.org \
--to=objecting@objecting.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
all inboxes | Powered by JetHome®