[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180405140250.aejexhnl7lppvyzb@pathway.suse.cz>
Date: Thu, 5 Apr 2018 16:02:50 +0200
From: Petr Mladek <pmladek@...e.com>
To: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
"Tobin C . Harding" <me@...in.cc>, Joe Perches <joe@...ches.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Michal Hocko <mhocko@...e.cz>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
linux-kernel@...r.kernel.org, Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH v4 7/9] vsprintf: Factor out %pO handler as
kobject_string()
On Thu 2018-04-05 08:35:11, Sergey Senozhatsky wrote:
> On (04/04/18 10:58), Petr Mladek wrote:
> > static noinline_for_stack
> > +char *kobject_string(char *buf, char *end, void *ptr,
> > + struct printf_spec spec, const char *fmt)
> > +{
> > + switch (fmt[1]) {
> > + case 'F':
> > + return device_node_string(buf, end, ptr, spec, fmt + 1);
> > + }
> > +
> > + WARN_ONCE(1, "Unsupported pointer format specifier: %%pO%c\n", fmt[1]);
> > + return buf;
> > +}
> > +
> > +static noinline_for_stack
> > char *pointer_string(char *buf, char *end, const void *ptr,
> > struct printf_spec spec)
> > {
> > @@ -1982,10 +1995,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
> > case 'G':
> > return flags_string(buf, end, ptr, fmt);
> > case 'O':
> > - switch (fmt[1]) {
> > - case 'F':
> > - return device_node_string(buf, end, ptr, spec, fmt + 1);
> > - }
> > + return kobject_string(buf, end, ptr, spec, fmt);
> > case 'x':
> > return pointer_string(buf, end, ptr, spec);
> > }
>
> So, previously, unsupported 'O' would end up in ptr_to_id()
No, it fallen through to pointer_string() because there was
missing "break". Therefore it eventually leaked the pointer.
Don't panic. It seems that all %pOF are correct in the mainline.
> case 'O':
> switch (fmt[1]) {
> case 'F':
> return device_node_string()
> }
> }
>
> return ptr_to_id();
>
>
>
> now we will just return `buf' without doing ptr_to_id()?
Yes, but it will also generate the WARNING. It should help people
undestand what is going on. We have no idea what the author
wanted to do. IMHO, it is confusing to show any random (address)
in that case.
Best Regards,
Petr
Powered by blists - more mailing lists