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 16:40:08 +0100 [thread overview]
Message-ID: <bcfb2f94-e7a8-0860-86e3-9fc866d98742@rasmusvillemoes.dk> (raw)
In-Reply-To: <20200219144558.2jbawr52qb63vysq@pathway.suse.cz>
On 19/02/2020 15.45, Petr Mladek wrote:
> On Wed 2020-02-19 14:56:32, Rasmus Villemoes wrote:
>> 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
>>> 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.
>
> OK, we should agree on some structure first.
>
> We already have two top level functions that test how a particular
> pointer is printed using different pointer modifiers:
>
> null_pointer(); -> NULL with %p, %pX, %pE
> invalid_pointer(); -> random pointer with %p, %pX, %pE
>
> Following this logic, errptr() should test how a pointer from IS_ERR() range
> is printed using different pointer formats.
Oh please. I wrote test_printf.c originally and structured it with one
helper for each %p<whatever>. How are your additions null_pointer and
invalid_pointer good examples for what the existing style is?
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 649)
test_pointer(void)
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 650) {
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 651) plain();
3e5903eb9cff7 (Petr Mladek 2019-04-17 13:53:48 +0200 652)
null_pointer();
3e5903eb9cff7 (Petr Mladek 2019-04-17 13:53:48 +0200 653)
invalid_pointer();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 654)
symbol_ptr();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 655)
kernel_ptr();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 656)
struct_resource();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 657) addr();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 658)
escaped_str();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 659)
hex_string();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 660) mac();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 661) ip();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 662) uuid();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 663) dentry();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 664)
struct_va_format();
4d42c44727a06 (Andy Shevchenko 2018-12-04 23:23:11 +0200 665)
struct_rtc_time();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 666)
struct_clk();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 667) bitmap();
707cc7280f452 (Rasmus Villemoes 2015-11-06 16:30:29 -0800 668)
netdev_features();
edf14cdbf9a0e (Vlastimil Babka 2016-03-15 14:55:56 -0700 669) flags();
57f5677e535ba (Rasmus Villemoes 2019-10-15 21:07:05 +0200 670) errptr();
f1ce39df508de (Sakari Ailus 2019-10-03 15:32:19 +0300 671)
fwnode_pointer();
> I am open to crate another logic but it must be consistent.
So yeah, I'm going to continue testing the behaviour of %pe in errptr, TYVM.
> If you want to check %pe with NULL in errptr(), you have to
> split the other two functions per-modifier. IMHO, it is not
> worth it.
Agreed, let's leave null_pointer and invalid_pointer alone.
>>>> BTW., your original patch for %p lacks corresponding update of
>>>> test_vsprintf.c. Please add appropriate test cases.
>>>
>>> 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).
>
> Yes, it would be great to add checks for %p, %px for IS_ERR() range.
> But it is different story. The above change is for the original patch
> and it was about NULL pointer handling.
Wrong. The original patch (i.e. Ilya's) had subject "vsprintf: don't
obfuscate NULL and error pointers" and did
+ if (IS_ERR_OR_NULL(ptr))
so the tests that should be part of that patch very much need to cover
both NULL and ERR_PTRs passed to plain %p.
Rasmus
next prev parent reply other threads:[~2020-02-19 15:40 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
2020-02-19 14:45 ` Petr Mladek
2020-02-19 15:38 ` Andy Shevchenko
2020-02-19 15:40 ` Rasmus Villemoes [this message]
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=bcfb2f94-e7a8-0860-86e3-9fc866d98742@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).