From: Petr Mladek <pmladek@suse.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Shuvam Pandey <shuvampandey1@gmail.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] printf: add bad-pointer tests for %ptT and %ptS
Date: Fri, 20 Mar 2026 09:54:17 +0100 [thread overview]
Message-ID: <ab0LOfwkATP-ptZG@pathway.suse.cz> (raw)
In-Reply-To: <abgZ6HGmN-E_OsGl@ashevche-desk.local>
On Mon 2026-03-16 16:55:36, Andy Shevchenko wrote:
> On Mon, Mar 16, 2026 at 04:43:34PM +0545, Shuvam Pandey wrote:
> > The printf KUnit suite exercises valid %ptR, %ptT, and %ptS inputs,
> > but it does not cover bad pointers for the time64_t and timespec64
> > paths.
> >
> > Add NULL and low-address pointer cases for %ptT and %ptS. The new
> > checks verify that time_and_date() rejects bad pointers before
> > dereferencing them and formats them as "(null)" or "(efault)".
> >
> > Validated with the printf KUnit suite on arm64 QEMU and an
> > incremental W=1 build of lib/tests/printf_kunit.o.
>
> NAK.
>
> It has nothing to do with %pt.
Let me play the devil advocate.
There is no single check which would catch bad pointers for
the various %p? format modifiers. It is because some of them
handle them differently, for example, %pK, %pe, or plain %p.
I want to say that wrong pointers passed to %pt? are caught only
because of the explicit check in:
static noinline_for_stack
char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
const char *fmt)
{
if (check_pointer(&buf, end, ptr, spec))
return buf;
[...]
}
So, pointer-modifier-specific checks of wrong input might make sense.
Of course, it would be nice to create some generic solution for
all affected pointer modifiers and not just for "%pt?".
Best Regards,
Petr
next prev parent reply other threads:[~2026-03-20 8:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 10:58 Shuvam Pandey
2026-03-16 14:55 ` Andy Shevchenko
2026-03-20 8:54 ` Petr Mladek [this message]
2026-03-20 10:29 ` Andy Shevchenko
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=ab0LOfwkATP-ptZG@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=shuvampandey1@gmail.com \
/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
Powered by JetHome