LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Petr Mladek <pmladek@suse.com>
Cc: Ilya Dryomov <idryomov@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Kees Cook <keescook@chromium.org>,
"Tobin C . Harding" <me@tobin.cc>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-doc@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] vsprintf: sanely handle NULL passed to %pe
Date: Wed, 19 Feb 2020 14:56:32 +0100 [thread overview]
Message-ID: <5459eb50-48e2-2fd9-3560-0bc921e3678c@rasmusvillemoes.dk> (raw)
In-Reply-To: <20200219134826.qqdhy2z67ubsnr2m@pathway.suse.cz>
On 19/02/2020 14.48, Petr Mladek wrote:
> On Wed 2020-02-19 12:53:22, Rasmus Villemoes wrote:
>> --- a/lib/vsprintf.c
>> +++ b/lib/vsprintf.c
>> @@ -619,7 +619,7 @@ static char *err_ptr(char *buf, char *end, void *ptr,
>> struct printf_spec spec)
>> {
>> int err = PTR_ERR(ptr);
>> - const char *sym = errname(err);
>> + const char *sym = err ? errname(err) : "NULL";
>
> I like this more than adding "NULL" errname.
OK.
>> if (sym)
>> return string_nocheck(buf, end, sym, spec);
>>
>> instead of the change(s) in errname.c? And then the test case for
>> '"%pe", NULL' should also be moved outside CONFIG_SYMBOLIC_ERRNAME.
>
> The test should go into null_pointer() instead of errptr().
Eh, no, the behaviour of %pe is tested by errptr(). I'll keep it that
way. But I should add a #else section that tests how %pe behaves without
CONFIG_SYMBOLIC_ERRNAME - though that's orthogonal to this patch.
> Could you send updated patch, please? ;-)
I'll wait a day or two for more comments. It doesn't seem very urgent.
>> BTW., your original patch for %p lacks corresponding update of
>> test_vsprintf.c. Please add appropriate test cases.
>
> Good point. The existing test_hashed() is rather weak
> and it did not catch this change.
>
> It would be nice to make test_hash() more powerful.
> Anyway, the minimal udpate would be:
>
> diff --git a/lib/test_printf.c b/lib/test_printf.c
> index 2d9f520d2f27..1726a678bccd 100644
> --- a/lib/test_printf.c
> +++ b/lib/test_printf.c
> @@ -333,7 +333,7 @@ test_hashed(const char *fmt, const void *p)
> static void __init
> null_pointer(void)
> {
> - test_hashed("%p", NULL);
> + test(ZEROS "00000000", "%p", NULL);
No, it most certainly also needs to check a few "%p", ERR_PTR(-4) cases
(where one of course has to use explicit integers and not E* constants).
Rasmus
next prev parent reply other threads:[~2020-02-19 13:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-17 22:28 [PATCH] vsprintf: don't obfuscate NULL and error pointers Ilya Dryomov
2020-02-17 23:47 ` Kees Cook
2020-02-18 0:07 ` Ilya Dryomov
2020-02-18 10:33 ` Petr Mladek
2020-02-18 11:16 ` Ilya Dryomov
2020-02-18 16:50 ` Steven Rostedt
2020-02-19 2:13 ` Sergey Senozhatsky
2020-02-18 18:49 ` Linus Torvalds
2020-02-18 19:31 ` Adam Borowski
2020-02-18 19:38 ` Linus Torvalds
2020-02-18 20:19 ` Ilya Dryomov
2020-02-18 20:21 ` Linus Torvalds
2020-02-19 7:30 ` Rasmus Villemoes
2020-02-19 8:21 ` [PATCH] vsprintf: sanely handle NULL passed to %pe Rasmus Villemoes
2020-02-19 9:35 ` Andy Shevchenko
2020-02-19 11:20 ` Ilya Dryomov
2020-02-19 11:25 ` Andy Shevchenko
2020-02-19 11:29 ` Ilya Dryomov
2020-02-19 11:53 ` Rasmus Villemoes
2020-02-19 13:48 ` Petr Mladek
2020-02-19 13:56 ` Rasmus Villemoes [this message]
2020-02-19 14:45 ` Petr Mladek
2020-02-19 15:38 ` Andy Shevchenko
2020-02-19 15:40 ` Rasmus Villemoes
2020-02-19 17:23 ` Ilya Dryomov
2020-02-20 12:57 ` Petr Mladek
2020-02-20 15:02 ` Ilya Dryomov
2020-02-21 13:05 ` Petr Mladek
2020-02-21 23:52 ` Rasmus Villemoes
2020-02-22 8:14 ` Andy Shevchenko
2020-02-24 9:55 ` Petr Mladek
2020-02-18 18:44 ` [PATCH] vsprintf: don't obfuscate NULL and error pointers Linus Torvalds
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=5459eb50-48e2-2fd9-3560-0bc921e3678c@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=idryomov@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@tobin.cc \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=torvalds@linux-foundation.org \
--subject='Re: [PATCH] vsprintf: sanely handle NULL passed to %pe' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).