As pointed out (and worked on a touch) in one of @awesomekling's latest videos, we need to start sanitizing pointers.
One method is to directly cut out all of the code that prints pointers, however then we will have a harder time debugging stuff.
Another method is to have a preprocessor definition (something like SANITIZE_KERNEL_POINTERS
) and wrap preprocessor statements around pointer-printing code.
A third method is to do something like what linux does:
The %pK format specifier is designed to hide exposed kernel pointers,
specifically via /proc interfaces. Exposing these pointers provides an
easy target for kernel write vulnerabilities, since they reveal the
locations of writable structures containing easily triggerable function
pointers. The behavior of %pK depends on the kptr_restrict sysctl.
If kptr_restrict is set to 0, no deviation from the standard %p behavior
occurs. If kptr_restrict is set to 1, the default, if the current user
(intended to be a reader via seq_printf(), etc.) does not have CAP_SYSLOG
(currently in the LSM tree), kernel pointers using %pK are printed as 0's.
If kptr_restrict is set to 2, kernel pointers using %pK are printed as
0's regardless of privileges. Replacing with 0's was chosen over the
default "(null)", which cannot be parsed by userland %p, which expects
"(nil)".
There are probably other methods of doing this, each with their own pros-cons. But I think this is something that will need to be done for the future π
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too