Re: [PATCH net-next v3] net: Replace %pK output with 0

Kees Cook <[email protected]>
Newsgroups org.kernel.vger.linux-can,org.kernel.vger.linux-sctp,org.kernel.vger.netdev
Message-ID <202608130949.A391CBF6@keescook>
On Wed, Aug 12, 2026 at 01:05:31PM +0200, Sebastian Andrzej Siewior wrote:
> Commit 71338aa7d050c ("net: convert %p usage to %pK") which is from
> 2011 and changed the %p annotation for pointer to %pK. Back then the
> default behaviour for %p was to print the pointer. The %pK modifier was
> introduced to able to control the behaviour of specific pointer values
> without changing the behaviour of %p for everyone. It was dedicated to
> avoid leaking pointers via /proc.
> 
> There was also the idea to remove the check from formatting the string
> and move to the open callback with some helpers but this did not happen.
> 
> Things changed over time. The default behaviour for %p is now to print a
> hash pointer which does not leak the address but allows to correlate if
> two pointers are equal.
> The policy on %p is to not introduce new ones. This is somehow in
> between since it already exists. The pointer are usually socket pointers
> and I don't see any value in exposing them. Therefore I am following the
> recommendation of removing them. Since their usage in /proc/ can be
> considered ABI I replace the pointer with a 0.
> 
> Replace the %pK annotation with 0 value. Correct the spacing for the
> cases where pointer is at the beginning. Use %ps in CAN where the read
> callback is used.
> 
> Signed-off-by: Sebastian Andrzej Siewior <[email protected]>

I love this kind of replacement. :)

Reviewed-by: Kees Cook <[email protected]>

-- 
Kees Cook
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.