Skip to contentSkip to conversation

docs: deprecated.rst: Add %p to the list

PATCH Superseded Kees Cook 2 participants 3 messages Mar 4, 2020 – Mar 5, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 docs: deprecated.rst: Add %p to the list

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.

---
 Documentation/process/deprecated.rst | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
Documentation/process/deprecated.rst +17 -0
index f9f196d3a69b..a4db119f4e09 100644
@@ -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
Signature · 5 lines
2.20.1


-- 
Kees Cook
#1 lore raw

Documentation/process/deprecated.rst the given limit of bytes to copy. This is inefficient and can lead to · line 114

Quoted 11 lines · Kees Cook
Documentation/process/deprecated.rst +3 -0
index f9f196d3a69b..a4db119f4e09 100644
@@ -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?

Documentation/process/deprecated.rst the given limit of bytes to copy. This is inefficient and can lead to · line 116

Quoted 2 lines
Documentation/process/deprecated.rst +2 -0
+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?

Quoted 1 line

If used currently, it is a hashed value, rendering it

Perhaps: s/it is/it prints/ ?

Quoted 2 lines

+unusable for addressing. Paraphrasing Linus's current `guideance
<https://lore.kernel.org/lkml/CA+55aFwQEd_d40g4mUCSsVRZzrFPUJt74vc6PPpb675hYNXcKw@mail.gmail.com/>`_:

Typo: guidance

Quoted 1 line

+- Just use %p and get the hashed value.

Signature · 1 line
James
author
#2 lore raw

Ah! A wild Troup appears! :)

Quoted 10 lines · James Troup
Quoted 8 lines · Kees Cook
Documentation/process/deprecated.rst +0 -0
index f9f196d3a69b..a4db119f4e09 100644
@@ -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`.
 
Quoted 6 lines

Documentation/process/deprecated.rst the given limit of bytes to copy. This is inefficient and can lead to · line 114

Quoted 3 lines
Documentation/process/deprecated.rst +3 -0
+%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.

Quoted 9 lines

Documentation/process/deprecated.rst the given limit of bytes to copy. This is inefficient and can lead to · line 116

Quoted 3 lines
Documentation/process/deprecated.rst +2 -0
+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?

Quoted 1 line

If used currently, it is a hashed value, rendering it

Perhaps: s/it is/it prints/ ?

I'll rewrite this whole area...

Quoted 5 lines
Quoted 3 lines

+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

Signature · 1 line
Kees Cook