| Refresh |
This website lore-kernel.gnuweeb.org/linux-doc/202003041103.A5842AD@keescook/t/ is currently offline. Cloudflare\'s Always Online™ shows a snapshot of this web page from the Internet Archive\'s Wayback Machine. To check for the live version, click Refresh. |
* [PATCH] docs: deprecated.rst: Add %p to the list @ 2020-03-04 19:13 Kees Cook 2020-03-05 6:22 ` James Troup 0 siblings, 1 reply; 3+ messages in thread From: Kees Cook @ 2020-03-04 19:13 UTC (permalink / raw) To: Jonathan Corbet; +Cc: Gustavo A. R. Silva, linux-doc, linux-kernel Once in a while %p usage comes up, and I've needed to have a reference to point people to. Add %p details to deprecated.rst. Signed-off-by: Kees Cook <keescook@chromium.org> --- Documentation/process/deprecated.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst index f9f196d3a69b..a4db119f4e09 100644 --- a/Documentation/process/deprecated.rst +++ b/Documentation/process/deprecated.rst @@ -109,6 +109,23 @@ the given limit of bytes to copy. This is inefficient and can lead to linear read overflows if a source string is not NUL-terminated. The safe replacement is :c:func:`strscpy`. +%p format specifier +------------------- +Using %p in format strings leads to a huge number of address exposures. +Instead of leaving these to be exploitable, "%p" should not be used in +the kernel. If used currently, it is a hashed value, rendering it +unusable for addressing. Paraphrasing Linus's current `guideance <https://lore.kernel.org/lkml/CA+55aFwQEd_d40g4mUCSsVRZzrFPUJt74vc6PPpb675hYNXcKw@mail.gmail.com/>`_: + +- Just use %p and get the hashed value. +- If the hashed value is pointless, ask yourself whether the pointer + itself is important. Maybe it should be removed entirely? +- As a last option, if you really think the true pointer value is + important, why is some system state or user privilege level considered + "special"? If it is well justified (in comments and commit log), maybe + you can use %px along with making sure you have sensible permissions. + +A system-wide toggle will `not be accepted <https://lore.kernel.org/lkml/CA+55aFwieC1-nAs+NFq9RTwaR8ef9hWa4MjNBWL41F-8wM49eA@mail.gmail.com/>`_. + Variable Length Arrays (VLAs) ----------------------------- Using stack VLAs produces much worse machine code than statically -- 2.20.1 -- Kees Cook ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] docs: deprecated.rst: Add %p to the list 2020-03-04 19:13 [PATCH] docs: deprecated.rst: Add %p to the list Kees Cook @ 2020-03-05 6:22 ` James Troup 2020-03-05 6:47 ` Kees Cook 0 siblings, 1 reply; 3+ messages in thread From: James Troup @ 2020-03-05 6:22 UTC (permalink / raw) To: Kees Cook; +Cc: Jonathan Corbet, Gustavo A. R. Silva, linux-doc, linux-kernel Kees Cook <keescook@chromium.org> writes: > diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst > index f9f196d3a69b..a4db119f4e09 100644 > --- a/Documentation/process/deprecated.rst > +++ b/Documentation/process/deprecated.rst > @@ -109,6 +109,23 @@ the given limit of bytes to copy. This is inefficient and can lead to > linear read overflows if a source string is not NUL-terminated. The > safe replacement is :c:func:`strscpy`. > > +%p format specifier > +------------------- > +Using %p in format strings leads to a huge number of address exposures. Perhaps this sentence should be in the past tense, since %p currently prints a hashed value? > +Instead of leaving these to be exploitable, "%p" should not be used in > +the kernel. On its face, this seems to contradict the guidance below? > If used currently, it is a hashed value, rendering it Perhaps: s/it is/it prints/ ? > +unusable for addressing. Paraphrasing Linus's current `guideance > <https://lore.kernel.org/lkml/CA+55aFwQEd_d40g4mUCSsVRZzrFPUJt74vc6PPpb675hYNXcKw@mail.gmail.com/>`_: Typo: guidance > +- Just use %p and get the hashed value. -- James ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] docs: deprecated.rst: Add %p to the list 2020-03-05 6:22 ` James Troup @ 2020-03-05 6:47 ` Kees Cook 0 siblings, 0 replies; 3+ messages in thread From: Kees Cook @ 2020-03-05 6:47 UTC (permalink / raw) To: James Troup; +Cc: Jonathan Corbet, Gustavo A. R. Silva, linux-doc, linux-kernel Ah! A wild Troup appears! :) On Thu, Mar 05, 2020 at 07:22:31AM +0100, James Troup wrote: > Kees Cook <keescook@chromium.org> writes: > > > diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst > > index f9f196d3a69b..a4db119f4e09 100644 > > --- a/Documentation/process/deprecated.rst > > +++ b/Documentation/process/deprecated.rst > > @@ -109,6 +109,23 @@ the given limit of bytes to copy. This is inefficient and can lead to > > linear read overflows if a source string is not NUL-terminated. The > > safe replacement is :c:func:`strscpy`. > > > > +%p format specifier > > +------------------- > > +Using %p in format strings leads to a huge number of address exposures. > > Perhaps this sentence should be in the past tense, since %p currently > prints a hashed value? Yeah, good point; that should be more clear. > > > +Instead of leaving these to be exploitable, "%p" should not be used in > > +the kernel. > > On its face, this seems to contradict the guidance below? > > > If used currently, it is a hashed value, rendering it > > Perhaps: s/it is/it prints/ ? I'll rewrite this whole area... > > > +unusable for addressing. Paraphrasing Linus's current `guideance > > <https://lore.kernel.org/lkml/CA+55aFwQEd_d40g4mUCSsVRZzrFPUJt74vc6PPpb675hYNXcKw@mail.gmail.com/>`_: > > Typo: guidance Thanks for the review! I wonder why ":set spell" missed that... -Kees -- Kees Cook ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-05 6:47 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-03-04 19:13 [PATCH] docs: deprecated.rst: Add %p to the list Kees Cook 2020-03-05 6:22 ` James Troup 2020-03-05 6:47 ` Kees Cook
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox