From: David Laight <David.Laight@ACULAB.COM>
To: 'Petr Mladek' <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
christophe leroy <christophe.leroy@c-s.fr>,
Linus Torvalds <torvalds@linux-foundation.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
"Tobin C . Harding" <me@tobin.cc>, Michal Hocko <mhocko@suse.cz>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Russell Currey <ruscur@russell.cc>,
Stephen Rothwell <sfr@ozlabs.org>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
linux-s390@vger.kernel.org
Subject: RE: [PATCH] vsprintf: Do not break early boot with probing addresses
Date: Wed, 15 May 2019 09:00:23 +0000 [thread overview]
Message-ID: <0a816ea272a0405f89d8ca7178604531@AcuMS.aculab.com> (raw)
In-Reply-To: <20190515073542.y6ru2nfagtcrpdl7@pathway.suse.cz>
From: Petr Mladek
> Sent: 15 May 2019 08:36
> On Tue 2019-05-14 14:37:51, Steven Rostedt wrote:
> >
> > [ Purple is a nice shade on the bike shed. ;-) ]
> >
> > On Tue, 14 May 2019 11:02:17 +0200
> > Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >
> > > On Tue, May 14, 2019 at 10:29 AM David Laight <David.Laight@aculab.com> wrote:
> > > > > And I like Steven's "(fault)" idea.
> > > > > How about this:
> > > > >
> > > > > if ptr < PAGE_SIZE -> "(null)"
> > > > > if IS_ERR_VALUE(ptr) -> "(fault)"
> > > > >
> > > > > -ss
> > > >
> > > > Or:
> > > > if (ptr < PAGE_SIZE)
> > > > return ptr ? "(null+)" : "(null)";
> >
> > Hmm, that is useful.
> >
> > > > if IS_ERR_VALUE(ptr)
> > > > return "(errno)"
> >
> > I still prefer "(fault)" as is pretty much all I would expect from a
> > pointer dereference, even if it is just bad parsing of, say, a parsing
> > an MAC address. "fault" is generic enough. "errno" will be confusing,
> > because that's normally a variable not a output.
> >
> > >
> > > Do we care about the value? "(-E%u)"?
> >
> > That too could be confusing. What would (-E22) be considered by a user
> > doing an sprintf() on some string. I know that would confuse me, or I
> > would think that it was what the %pX displayed, and wonder why it
> > displayed it that way. Whereas "(fault)" is quite obvious for any %p
> > use case.
>
> This discussion clearly shows that it is hard to make anyone happy.
>
> I considered switching to "(fault)" because there seems to be more
> people in favor of this.
>
> But there is used also "(einval)" when an unsupported pointer
> modifier is passed. The idea is to show error codes that people
> are familiar with.
>
> It might have been better to use the uppercase "(EFAULT)" and
> "(EINVAL)" to make it more obvious. But I wanted to follow
> the existing style with the lowercase "(null)".
Printing 'fault' when the code was (trying to) validate the
address was ok.
When the only check is for an -errno value it seems wrong as
most invalid addresses will actually fault (and panic).
The reason modern printf generate "(null)" is that it is far too
easy for a diagnostic print to fail to test a pointer.
It also makes it easier when 'throwing in' printf while debugging
to add a single trace that will work regardless of whether a
call had succeeded or not.
With the Linux kernel putting errno values into pointers it
seems likely that most invalid pointers in printf will actaully
be error values.
Printing the value will be helpful during debugging - as a
trace can be put after a call and show the parameters and result.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2019-05-15 9:00 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190509121923.aQycz_mOWrrZRdG61KMh7qtBiiaqDuu5CXB5Ufi79nE@z>
2019-05-09 12:19 ` [PATCH] vsprintf: Do not break early boot with probing addresses Petr Mladek
[not found] ` <20190509130512.eOpTHWX1Vw219J1juYw-SpeQRpBzQZT5CGSN2gh29i4@z>
2019-05-09 13:05 ` Andy Shevchenko
[not found] ` <20190509131357.ae3kG3RqVx9kjP66InzbRDur4-P1bAbE2QdMj6Mn17c@z>
2019-05-09 13:13 ` Steven Rostedt
[not found] ` <20190509140609.pGTLvlSQI_xy_YFvhBzkQV7ZWu_ABMDICwAH3s7J8IA@z>
2019-05-09 14:06 ` Petr Mladek
[not found] ` <20190509133829.35pSRgEMpcLhNbfDUK9sCV-aSZSNvQEOVDu8hmrRnzU@z>
2019-05-09 13:38 ` Michal Suchánek
[not found] ` <20190509134659.kYjGd-skkWNID8rAreeNzTDTLfzq382O0FQCZ5calZI@z>
2019-05-09 13:46 ` David Laight
2019-05-10 10:21 ` Michael Ellerman
[not found] ` <20190510043200.8FxCQhSO0N0LIZ4YtumRMpgw45VDU75TKeSE5eHU2dc@z>
2019-05-10 4:32 ` Sergey Senozhatsky
2019-05-10 4:47 ` Linus Torvalds
[not found] ` <20190510050709.ugUsmdWEg2-_zeuhzXY9dG3VOFvC7DcdjoUsQ1gSOxk@z>
2019-05-10 5:07 ` Sergey Senozhatsky
[not found] ` <20190510064124.q7J_CwuPPeHjW5ZMFj9t16uRiB6ATm6nxxi7Biu_ngY@z>
2019-05-10 6:41 ` Michael Ellerman
[not found] ` <20190510080602.36-virBOPDomDAXDbVYusr-C7NH4SabZGccCMnPdJH4@z>
2019-05-10 8:06 ` Petr Mladek
2019-05-10 8:16 ` Sergey Senozhatsky
[not found] ` <20190510084213.8Fn-MjbMg2bybTStBKHj9OvLB7rut0bqt0KPaIdXS6w@z>
2019-05-10 8:42 ` Petr Mladek
[not found] ` <20190510085121.odNKC0TIP5NjjMowx6VFDfGImLYzeJZz8lrq7Yx7_hk@z>
2019-05-10 8:51 ` Sergey Senozhatsky
[not found] ` <20190510144917.9fXSsk7NOInbDA76CH7cG3WBj0FI-4Dwb2Tk9_C4zpU@z>
2019-05-10 14:49 ` Petr Mladek
[not found] ` <20190510162401.zyjRI2h57ECWKi8XIr7nNNUOwR44kpMVP_pAyDYOETo@z>
2019-05-10 16:24 ` Steven Rostedt
[not found] ` <20190510163258.qn3246r2dHdhqWhvmxZO4mIbhuwcSMjfnXQQlH0ZaHs@z>
2019-05-10 16:32 ` Martin Schwidefsky
[not found] ` <20190510164058.TGQUcmQqwQN4_qlomMwU48TPGVQzXQVM4L1sbRoiVqY@z>
2019-05-10 16:40 ` Steven Rostedt
[not found] ` <20190510164548.hSfrXK8q_ZGsqqE57NiR7n0OFDEvIcwdE7j7PZU7lac@z>
2019-05-10 16:45 ` Martin Schwidefsky
[not found] ` <20190513122424.Bzyc5wNhgHc3y9K3Vn-j74_9etFbZZ5gQ1QPdKl6DWc@z>
2019-05-13 12:24 ` Petr Mladek
[not found] ` <20190510164134.MOFEXv4lZ0byKuO5xFyCeqdaA9zePgipycDNWtjfBrg@z>
2019-05-10 16:41 ` Andy Shevchenko
[not found] ` <20190510173529.XATeuZJ4qvPsIGIrHM2kfdN6CdMiyb6gddK2hUaBa-I@z>
2019-05-10 17:35 ` christophe leroy
[not found] ` <20190513085241.CwbAqRfT4AD-BNv6ycJNL377JFUjP7hKf_PblscZCMA@z>
2019-05-13 8:52 ` David Laight
[not found] ` <20190513091320.1ZqC-JL0QLpgZiAEDAqK_gfjSO6wDFbjpn4v4t2QXOE@z>
2019-05-13 9:13 ` Andy Shevchenko
[not found] ` <20190513124220.pxn2l_kLvtCUhSGnQPpm0fECHh3Y6INT5S5RWf6pfe4@z>
2019-05-13 12:42 ` Petr Mladek
[not found] ` <20190513141550.nMZbc9Db_wQfUJwYwkQTsbqWEg3wp15GgYxSKNUijyQ@z>
2019-05-13 14:15 ` Steven Rostedt
[not found] ` <20190514020730.g4cTS2GpqhzzEgKbRibvfxOK38Jika-NdjcqZLJn1As@z>
2019-05-14 2:07 ` Sergey Senozhatsky
[not found] ` <20190514022526.vllOcw77HB9TYfH3e8ZSGlZ1g_E72jw6dA10uIIz-Dw@z>
2019-05-14 2:25 ` Sergey Senozhatsky
[not found] ` <20190514082821.vHA7v2O08oEYQIonTCUC1XbIM9aVA42znGjzYx0yqEA@z>
2019-05-14 8:28 ` David Laight
[not found] ` <20190514090217.YS1_XeAyyiXu8TPl6BFDc3rpbtL4aynuSYfokOJWYaU@z>
2019-05-14 9:02 ` Geert Uytterhoeven
[not found] ` <20190514183751.e9m7K3oevIRrilsKNzAtPbZ1iFL7XriqpwHrBnk9krU@z>
2019-05-14 18:37 ` Steven Rostedt
[not found] ` <20190514191306.iYLu_pdr2N7Q3pR0cC87rvIUTuczSZBRSyh5RyX1ny0@z>
2019-05-14 19:13 ` Geert Uytterhoeven
[not found] ` <20190514193503.XdZN4DHnv7PT3ysPIU9r8z4k2mgdzV7WD0-q-GTF5Zk@z>
2019-05-14 19:35 ` Steven Rostedt
[not found] ` <20190515072305.E1DEATG-MTVuAOpUj2pEKMYi_9cV96M6GcmiMB3QY8Q@z>
2019-05-15 7:23 ` Geert Uytterhoeven
[not found] ` <20190515075339.CYb8ZQm6zt6Kfk3OqcAqbBwh7Xb51oxEZ6kRCINiTz8@z>
2019-05-15 7:53 ` Petr Mladek
[not found] ` <20190515062111.T5hZGjKZK2a2swDTBpkbB4UbIVTKWVNPATVUxxRnwVM@z>
2019-05-15 6:21 ` Sergey Senozhatsky
[not found] ` <20190515073542.1LbG-sjR-mgtUP_Qb2B1cDfKE6rXwecam2gTdfB60ro@z>
2019-05-15 7:35 ` Petr Mladek
2019-05-15 9:00 ` David Laight [this message]
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=0a816ea272a0405f89d8ca7178604531@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=christophe.leroy@c-s.fr \
--cc=geert@linux-m68k.org \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=me@tobin.cc \
--cc=mhocko@suse.cz \
--cc=mpe@ellerman.id.au \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=ruscur@russell.cc \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=sfr@ozlabs.org \
--cc=torvalds@linux-foundation.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