Skip to contentSkip to conversation

kptr_restrict for hiding kernel pointers from unprivileged users

PATCH Eugene Teo 1 participant 1 message Dec 15, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Eugene Teo

author Acked-by
#1 lore raw
In reply to a message not in the archive
Quoted 19 lines · Dan Rosenberg

The below patch adds the %pK format specifier, the CONFIG_SECURITY_KPTR_RESTRICT configuration option, and the kptr_restrict sysctl.

The %pK format specifier is designed to hide exposed kernel pointers from unprivileged users, specifically via /proc interfaces. Its behavior depends on the kptr_restrict sysctl, whose default value depends on CONFIG_SECURITY_KPTR_RESTRICT. If kptr_restrict is set to 0, no deviation from the standard %p behavior occurs. If kptr_restrict is set to 1, if the current user (intended to be a reader via seq_printf(), etc.) does not have CAP_SYSLOG (which is currently in the LSM tree), kernel pointers using %pK are printed as 0's. This was chosen over the default "(null)", which cannot be parsed by userland %p, which expects "(nil)".

v2 improves checking for inappropriate context, on suggestion by Peter Zijlstra. Thanks to Thomas Graf for suggesting use of a centralized format specifier.

Quoted 8 lines
CC James Morris <[email protected]>
CC Eugene Teo <[email protected]>
CC Kees Cook <[email protected]>
CC Ingo Molnar <[email protected]>
CC David S. Miller <[email protected]>

Eugene