linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] docs: deprecated.rst: Add %p to the list
@ 2020-03-05  7:03 Kees Cook
  2020-03-10 17:19 ` Jonathan Corbet
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2020-03-05  7:03 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: James Troup, 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>
---
v2: rewrite much of the text to be more clear (James Troup)
---
 Documentation/process/deprecated.rst | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
index f9f196d3a69b..8965446f0b71 100644
--- a/Documentation/process/deprecated.rst
+++ b/Documentation/process/deprecated.rst
@@ -109,6 +109,28 @@ 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
+-------------------
+Traditionally, using "%p" in format strings would lead to regular address
+exposure flaws in dmesg, proc, sysfs, etc. Instead of leaving these to
+be exploitable, all "%p" uses in the kernel are being printed as a hashed
+value, rendering them unusable for addressing. New uses of "%p" should not
+be added to the kernel. For text addresses, using "%pS" is likely better,
+as it produces the more useful symbol name instead. For nearly everything
+else, just do not add "%p" at all.
+
+Paraphrasing Linus's current `guidance <https://lore.kernel.org/lkml/CA+55aFwQEd_d40g4mUCSsVRZzrFPUJt74vc6PPpb675hYNXcKw@mail.gmail.com/>`_:
+
+- If the hashed "%p" value is pointless, ask yourself whether the pointer
+  itself is important. Maybe it should be removed entirely?
+- If you really think the true pointer value is important, why is some
+  system state or user privilege level considered "special"? If you think
+  you can justify it (in comments and commit log) well enough to stand
+  up to Linus's scrutiny, maybe you can use "%px", along with making sure
+  you have sensible permissions.
+
+And finally, know that a toggle for "%p" hashing 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] 2+ messages in thread

* Re: [PATCH v2] docs: deprecated.rst: Add %p to the list
  2020-03-05  7:03 [PATCH v2] docs: deprecated.rst: Add %p to the list Kees Cook
@ 2020-03-10 17:19 ` Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2020-03-10 17:19 UTC (permalink / raw)
  To: Kees Cook; +Cc: James Troup, Gustavo A. R. Silva, linux-doc, linux-kernel

On Wed, 4 Mar 2020 23:03:47 -0800
Kees Cook <keescook@chromium.org> wrote:

> 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>
> ---
> v2: rewrite much of the text to be more clear (James Troup)

Applied, thanks.

jon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-10 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-05  7:03 [PATCH v2] docs: deprecated.rst: Add %p to the list Kees Cook
2020-03-10 17:19 ` Jonathan Corbet

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).