Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH net-next] net: Convert %pK back to %p
@ 2026-07-06  7:38 Sebastian Andrzej Siewior
  2026-07-07  7:46 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-07-06  7:38 UTC (permalink / raw)
  To: linux-atm-general, linux-can, linux-sctp, netdev
  Cc: David S. Miller, Eric Dumazet, Herbert Xu, Jakub Kicinski,
	Kuniyuki Iwashima, Marc Kleine-Budde, Marcelo Ricardo Leitner,
	Neal Cardwell, Oliver Hartkopp, Paolo Abeni, Remi Denis-Courmont,
	Simon Horman, Steffen Klassert, Willem de Bruijn, Xin Long,
	Petr Mladek, Thomas Weißschuh, Kees Cook

This is a revert of commit 71338aa7d050c ("net: convert %p usage to
%pK") which is from 2011. Back then the default behaviour for %p was to
print the pointer. The %pK modifier was introduced to be able to control
the behaviour of specific pointer output 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 (of the /proc file) 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 pointer to hash value mapping
is not stable across reboots so one can not precompute the values and
have a lookup table. There is also the `hash_pointers' boot argument
which allows to disable it and print real pointers if needed. The
default behaviour of %pK (kptr_restrict==0) is already %p (hashed
pointer).

The %pK modifier brings hardly and value over %p. Removing it allows to
remove the policy checks from pointer formatting.

Switch back to the %p modifier.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---

My long term goal is remove the restricted_pointer() handling from
vsprintf. I don't see any benefit in having it and case kptr_restrict==1
caused problems in terms of locking. Instead of attempting to get the
debug/ warn infrastructure right I am for removing it.

 net/atm/proc.c           | 2 +-
 net/can/bcm.c            | 6 +++---
 net/can/proc.c           | 4 ++--
 net/ipv4/ping.c          | 2 +-
 net/ipv4/raw.c           | 2 +-
 net/ipv4/tcp_ipv4.c      | 6 +++---
 net/ipv4/udp.c           | 2 +-
 net/ipv6/datagram.c      | 2 +-
 net/ipv6/tcp_ipv6.c      | 6 +++---
 net/key/af_key.c         | 2 +-
 net/netlink/af_netlink.c | 2 +-
 net/packet/af_packet.c   | 2 +-
 net/phonet/socket.c      | 2 +-
 net/sctp/proc.c          | 4 ++--
 net/unix/af_unix.c       | 2 +-
 15 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/net/atm/proc.c b/net/atm/proc.c
index 8f20b49b9c02a..2c39364edf929 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -159,7 +159,7 @@ static void vcc_info(struct seq_file *seq, struct atm_vcc *vcc)
 {
 	struct sock *sk = sk_atm(vcc);
 
-	seq_printf(seq, "%pK ", vcc);
+	seq_printf(seq, "%p ", vcc);
 	if (!vcc->dev)
 		seq_printf(seq, "Unassigned    ");
 	else
diff --git a/net/can/bcm.c b/net/can/bcm.c
index a4bef2c48a559..ce3650932d5cd 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -213,9 +213,9 @@ static int bcm_proc_show(struct seq_file *m, void *v)
 	struct bcm_sock *bo = bcm_sk(sk);
 	struct bcm_op *op;
 
-	seq_printf(m, ">>> socket %pK", sk->sk_socket);
-	seq_printf(m, " / sk %pK", sk);
-	seq_printf(m, " / bo %pK", bo);
+	seq_printf(m, ">>> socket %p", sk->sk_socket);
+	seq_printf(m, " / sk %p", sk);
+	seq_printf(m, " / bo %p", bo);
 	seq_printf(m, " / dropped %lu", bo->dropped_usr_msgs);
 	seq_printf(m, " / bound %s", bcm_proc_getifname(net, ifname, bo->ifindex));
 	seq_printf(m, " <<<\n");
diff --git a/net/can/proc.c b/net/can/proc.c
index de4d05ae34597..1f2611b0ccfc1 100644
--- a/net/can/proc.c
+++ b/net/can/proc.c
@@ -192,8 +192,8 @@ static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list,
 
 	hlist_for_each_entry_rcu(r, rx_list, list) {
 		char *fmt = (r->can_id & CAN_EFF_FLAG)?
-			"   %-5s  %08x  %08x  %pK  %pK  %8ld  %s\n" :
-			"   %-5s     %03x    %08x  %pK  %pK  %8ld  %s\n";
+			"   %-5s  %08x  %08x  %p  %p  %8ld  %s\n" :
+			"   %-5s     %03x    %08x  %p  %p  %8ld  %s\n";
 
 		seq_printf(m, fmt, DNAME(dev), r->can_id, r->mask,
 			   r->func, r->data, atomic_long_read(&r->matches),
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index d36f1e273fde4..d66811d825eba 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1095,7 +1095,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
 	__u16 srcp = ntohs(inet->inet_sport);
 
 	seq_printf(f, "%5d: %08X:%04X %08X:%04X"
-		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %pK %u",
+		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %p %u",
 		bucket, src, srcp, dest, destp, sp->sk_state,
 		sk_wmem_alloc_get(sp),
 		sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 2aebaf8297e04..c7ef95f8eb2c6 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -1045,7 +1045,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
 	      srcp  = inet->inet_num;
 
 	seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
-		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %pK %u\n",
+		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %p %u\n",
 		i, src, srcp, dest, destp, sp->sk_state,
 		sk_wmem_alloc_get(sp),
 		sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 209ef7522508f..aa31af06e5e3b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2743,7 +2743,7 @@ static void get_openreq4(const struct request_sock *req,
 	long delta = req->rsk_timer.expires - jiffies;
 
 	seq_printf(f, "%4d: %08X:%04X %08X:%04X"
-		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %u %d %pK",
+		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %u %d %p",
 		i,
 		ireq->ir_loc_addr,
 		ireq->ir_num,
@@ -2806,7 +2806,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
 				      READ_ONCE(tp->copied_seq), 0);
 
 	seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
-			"%08X %5u %8d %llu %d %pK %lu %lu %u %u %d",
+			"%08X %5u %8d %llu %d %p %lu %lu %u %u %d",
 		i, src, srcp, dest, destp, state,
 		READ_ONCE(tp->write_seq) - tp->snd_una,
 		rx_queue,
@@ -2839,7 +2839,7 @@ static void get_timewait4_sock(const struct inet_timewait_sock *tw,
 	srcp  = ntohs(tw->tw_sport);
 
 	seq_printf(f, "%4d: %08X:%04X %08X:%04X"
-		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK",
+		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p",
 		i, src, srcp, dest, destp, READ_ONCE(tw->tw_substate), 0, 0,
 		3, jiffies_delta_to_clock_t(delta), 0, 0, 0, 0,
 		refcount_read(&tw->tw_refcnt), tw);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 59248a59358ca..db3c90f9a56de 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -3280,7 +3280,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
 	__u16 srcp	  = ntohs(inet->inet_sport);
 
 	seq_printf(f, "%5d: %08X:%04X %08X:%04X"
-		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %pK %u",
+		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %p %u",
 		bucket, src, srcp, dest, destp, sp->sk_state,
 		sk_wmem_alloc_get(sp),
 		udp_rqueue_get(sp),
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 38d7b48452817..7cfacc06a331c 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -1102,7 +1102,7 @@ void __ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
 	src   = &sp->sk_v6_rcv_saddr;
 	seq_printf(seq,
 		   "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-		   "%02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %pK %u\n",
+		   "%02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %p %u\n",
 		   bucket,
 		   src->s6_addr32[0], src->s6_addr32[1],
 		   src->s6_addr32[2], src->s6_addr32[3], srcp,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index ebe161d72fbd0..e370b47171ce8 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2099,7 +2099,7 @@ static void get_openreq6(struct seq_file *seq,
 
 	seq_printf(seq,
 		   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-		   "%02X %08X:%08X %02X:%08lX %08X %5u %8d %d %d %pK\n",
+		   "%02X %08X:%08X %02X:%08lX %08X %5u %8d %d %d %p\n",
 		   i,
 		   src->s6_addr32[0], src->s6_addr32[1],
 		   src->s6_addr32[2], src->s6_addr32[3],
@@ -2167,7 +2167,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
 
 	seq_printf(seq,
 		   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-		   "%02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %pK %lu %lu %u %u %d\n",
+		   "%02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %p %lu %lu %u %u %d\n",
 		   i,
 		   src->s6_addr32[0], src->s6_addr32[1],
 		   src->s6_addr32[2], src->s6_addr32[3], srcp,
@@ -2207,7 +2207,7 @@ static void get_timewait6_sock(struct seq_file *seq,
 
 	seq_printf(seq,
 		   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-		   "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK\n",
+		   "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n",
 		   i,
 		   src->s6_addr32[0], src->s6_addr32[1],
 		   src->s6_addr32[2], src->s6_addr32[3], srcp,
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 1d8965d7f4f3c..4df706789280f 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3805,7 +3805,7 @@ static int pfkey_seq_show(struct seq_file *f, void *v)
 	if (v == SEQ_START_TOKEN)
 		seq_printf(f ,"sk       RefCnt Rmem   Wmem   User   Inode\n");
 	else
-		seq_printf(f, "%pK %-6d %-6u %-6u %-6u %-6llu\n",
+		seq_printf(f, "%p %-6d %-6u %-6u %-6u %-6llu\n",
 			       s,
 			       refcount_read(&s->sk_refcnt),
 			       sk_rmem_alloc_get(s),
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 5202fe0b08671..48a1996f897b9 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2706,7 +2706,7 @@ static int netlink_native_seq_show(struct seq_file *seq, void *v)
 		struct sock *s = v;
 		struct netlink_sock *nlk = nlk_sk(s);
 
-		seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8u %-8llu\n",
+		seq_printf(seq, "%p %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8u %-8llu\n",
 			   s,
 			   s->sk_protocol,
 			   nlk->portid,
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 8e6f3a734ba0b..fd22ff5677ebc 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -4726,7 +4726,7 @@ static int packet_seq_show(struct seq_file *seq, void *v)
 		const struct packet_sock *po = pkt_sk(s);
 
 		seq_printf(seq,
-			   "%pK %-6d %-4d %04x   %-5d %1d %-6u %-6u %-6llu\n",
+			   "%p %-6d %-4d %04x   %-5d %1d %-6u %-6u %-6llu\n",
 			   s,
 			   refcount_read(&s->sk_refcnt),
 			   s->sk_type,
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 631a99cdbd006..eefdb788be592 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -586,7 +586,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
 		struct pn_sock *pn = pn_sk(sk);
 
 		seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %llu "
-			"%d %pK %u",
+			"%d %p %u",
 			sk->sk_protocol, pn->sobject, pn->dobject,
 			pn->resource, sk->sk_state,
 			sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 43433d7e2acd7..cd99d634fa6d6 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -174,7 +174,7 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
 		sk = ep->base.sk;
 		if (!net_eq(sock_net(sk), seq_file_net(seq)))
 			continue;
-		seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5u %5llu ", ep, sk,
+		seq_printf(seq, "%8p %8p %-3d %-3d %-4d %-5d %5u %5llu ", ep, sk,
 			   sctp_sk(sk)->type, sk->sk_state, hash,
 			   ep->base.bind_addr.port,
 			   from_kuid_munged(seq_user_ns(seq), sk_uid(sk)),
@@ -260,7 +260,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
 	sk = epb->sk;
 
 	seq_printf(seq,
-		   "%8pK %8pK %-3d %-3d %-2d %-4d "
+		   "%8p %8p %-3d %-3d %-2d %-4d "
 		   "%4d %8d %8d %7u %5llu %-5d %5d ",
 		   assoc, sk, sctp_sk(sk)->type, sk->sk_state,
 		   assoc->state, 0,
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index f7a9d55eee8a1..6a8174977c87a 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -3554,7 +3554,7 @@ static int unix_seq_show(struct seq_file *seq, void *v)
 		struct unix_sock *u = unix_sk(s);
 		unix_state_lock(s);
 
-		seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5llu",
+		seq_printf(seq, "%p: %08X %08X %08X %04X %02X %5llu",
 			s,
 			refcount_read(&s->sk_refcnt),
 			0,
-- 
2.53.0


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

* Re: [PATCH net-next] net: Convert %pK back to %p
  2026-07-06  7:38 [PATCH net-next] net: Convert %pK back to %p Sebastian Andrzej Siewior
@ 2026-07-07  7:46 ` sashiko-bot
  2026-07-07  9:37   ` Sebastian Andrzej Siewior
  2026-07-09 11:28 ` Petr Mladek
  2026-07-09 16:18 ` Kees Cook
  2 siblings, 1 reply; 5+ messages in thread
From: sashiko-bot @ 2026-07-07  7:46 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Marc Kleine-Budde, Oliver Hartkopp, Oleksij Rempel, linux-can,
	Vincent Mailhol

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Replacing `%pK` with `%p` breaks userspace tracing ABI and `kptr_restrict` runtime configurability.
- [Medium] Incomplete refactoring misses `net/bluetooth/af_bluetooth.c`, leaving inconsistent pointer formatting behavior.
--

commit b2c57f416d95fe882e14b5fd13915b835f475930
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

net: Convert %pK back to %p

This commit reverts a 2011 change that converted %p usage to %pK in the
networking subsystem. It replaces %pK with %p across various procfs output
files, stating that %p now defaults to a hashed pointer anyway.

> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index 209ef7522508f..aa31af06e5e3b 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c

[ ... ]

> @@ -2806,7 +2806,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
>  				      READ_ONCE(tp->copied_seq), 0);
>  
>  	seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
> -			"%08X %5u %8d %llu %d %pK %lu %lu %u %u %d",
> +			"%08X %5u %8d %llu %d %p %lu %lu %u %u %d",

[Severity: Critical]
Does replacing %pK with %p in get_tcp4_sock() break the userspace tracing
ABI and bypass the kernel.kptr_restrict sysctl?

Under kptr_restrict=1 (the default on most distributions), %pK returns the
raw kernel pointer to users with the syslog capability. By reverting to %p,
a hashed pointer is unconditionally returned instead. 

While the commit message notes that hash_pointers can be disabled at boot,
does this break the runtime configurability provided by the
kernel.kptr_restrict sysctl? 

Will existing tracing tools that correlate /proc sockets with kernel memory
receive hashes and fail instead of raw pointers?

[ ... ]

> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index f7a9d55eee8a1..6a8174977c87a 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c

[ ... ]

> @@ -3554,7 +3554,7 @@ static int unix_seq_show(struct seq_file *seq, void *v)
>  		struct unix_sock *u = unix_sk(s);
>  		unix_state_lock(s);
>  
> -		seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5llu",
> +		seq_printf(seq, "%p: %08X %08X %08X %04X %02X %5llu",

[Severity: Critical]
Does this also expose unix socket structures directly as hashed pointers in
unix_seq_show(), bypassing sysctl restrictions?

Similar to the tcp change above, will tracing tools no longer be able to
resolve these pointers when kptr_restrict=1 is set?

[ ... ]

[Severity: Medium]
Does this commit leave the networking subsystem in an inconsistent state by
missing net/bluetooth/af_bluetooth.c?

Looking at bt_seq_show() in net/bluetooth/af_bluetooth.c, it still uses %pK:

    seq_printf(f, "%pK %-6d %-6u %-6u %-6u %-6llu %-6llu",

Is this the only remaining use of %pK in the net/ subsystem that was missed
by the refactoring? This appears to leave bluetooth procfs files respecting
kptr_restrict while the other protocols do not.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260706073824.xixrLxoD@linutronix.de?part=1

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

* Re: [PATCH net-next] net: Convert %pK back to %p
  2026-07-07  7:46 ` sashiko-bot
@ 2026-07-07  9:37   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-07-07  9:37 UTC (permalink / raw)
  To: sashiko-reviews
  Cc: Marc Kleine-Budde, Oliver Hartkopp, Oleksij Rempel, linux-can,
	Vincent Mailhol

On 2026-07-07 07:46:53 [+0000], sashiko-bot@kernel.org wrote:
> > @@ -2806,7 +2806,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
> >  				      READ_ONCE(tp->copied_seq), 0);
> >  
> >  	seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
> > -			"%08X %5u %8d %llu %d %pK %lu %lu %u %u %d",
> > +			"%08X %5u %8d %llu %d %p %lu %lu %u %u %d",
> 
> [Severity: Critical]
> Does replacing %pK with %p in get_tcp4_sock() break the userspace tracing
> ABI and bypass the kernel.kptr_restrict sysctl?
> 
> Under kptr_restrict=1 (the default on most distributions), %pK returns the
> raw kernel pointer to users with the syslog capability. By reverting to %p,
> a hashed pointer is unconditionally returned instead. 

Debian and Arch have kptr_restrict=0 by default as far as I can tell. A
hashed pointer is still useful for tracing it is just not the actual
address which can be used in reading the content from memory.

> While the commit message notes that hash_pointers can be disabled at boot,
> does this break the runtime configurability provided by the
> kernel.kptr_restrict sysctl? 

It is not documented which pointers are controlled by which knob. So
this unites this.

> Will existing tracing tools that correlate /proc sockets with kernel memory
> receive hashes and fail instead of raw pointers?

It still can correlate pointers.

> > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> > index f7a9d55eee8a1..6a8174977c87a 100644
> > --- a/net/unix/af_unix.c
> > +++ b/net/unix/af_unix.c
> 
> [ ... ]
> 
> > @@ -3554,7 +3554,7 @@ static int unix_seq_show(struct seq_file *seq, void *v)
> >  		struct unix_sock *u = unix_sk(s);
> >  		unix_state_lock(s);
> >  
> > -		seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5llu",
> > +		seq_printf(seq, "%p: %08X %08X %08X %04X %02X %5llu",
> 
> [Severity: Critical]
> Does this also expose unix socket structures directly as hashed pointers in
> unix_seq_show(), bypassing sysctl restrictions?

hashed pointers do not reveal actual pointers.

> Similar to the tcp change above, will tracing tools no longer be able to
> resolve these pointers when kptr_restrict=1 is set?

I don't think tracing tool need to resolve pointers. They just care if
they are the same.

> [ ... ]
> 
> [Severity: Medium]
> Does this commit leave the networking subsystem in an inconsistent state by
> missing net/bluetooth/af_bluetooth.c?
> 
> Looking at bt_seq_show() in net/bluetooth/af_bluetooth.c, it still uses %pK:
> 
>     seq_printf(f, "%pK %-6d %-6u %-6u %-6u %-6llu %-6llu",
> 
> Is this the only remaining use of %pK in the net/ subsystem that was missed
> by the refactoring? This appears to leave bluetooth procfs files respecting
> kptr_restrict while the other protocols do not.

This is staged for the BT tree.

Sebastian

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

* Re: [PATCH net-next] net: Convert %pK back to %p
  2026-07-06  7:38 [PATCH net-next] net: Convert %pK back to %p Sebastian Andrzej Siewior
  2026-07-07  7:46 ` sashiko-bot
@ 2026-07-09 11:28 ` Petr Mladek
  2026-07-09 16:18 ` Kees Cook
  2 siblings, 0 replies; 5+ messages in thread
From: Petr Mladek @ 2026-07-09 11:28 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-atm-general, linux-can, linux-sctp, netdev, David S. Miller,
	Eric Dumazet, Herbert Xu, Jakub Kicinski, Kuniyuki Iwashima,
	Marc Kleine-Budde, Marcelo Ricardo Leitner, Neal Cardwell,
	Oliver Hartkopp, Paolo Abeni, Remi Denis-Courmont, Simon Horman,
	Steffen Klassert, Willem de Bruijn, Xin Long,
	Thomas Weißschuh, Kees Cook

On Mon 2026-07-06 09:38:24, Sebastian Andrzej Siewior wrote:
> This is a revert of commit 71338aa7d050c ("net: convert %p usage to
> %pK") which is from 2011. Back then the default behaviour for %p was to
> print the pointer. The %pK modifier was introduced to be able to control
> the behaviour of specific pointer output 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 (of the /proc file) 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 pointer to hash value mapping
> is not stable across reboots so one can not precompute the values and
> have a lookup table. There is also the `hash_pointers' boot argument
> which allows to disable it and print real pointers if needed. The
> default behaviour of %pK (kptr_restrict==0) is already %p (hashed
> pointer).
> 
> The %pK modifier brings hardly and value over %p. Removing it allows to
> remove the policy checks from pointer formatting.

Yes, I believe that the %pK behavior has been obsoleted by hashing
pointers printed via %p by default and hash_pointers= boot parameter.

> My long term goal is remove the restricted_pointer() handling from
> vsprintf. I don't see any benefit in having it and case kptr_restrict==1
> caused problems in terms of locking. Instead of attempting to get the
> debug/ warn infrastructure right I am for removing it.

Yes, it would be nice because the locking is tricky.

Acked-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

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

* Re: [PATCH net-next] net: Convert %pK back to %p
  2026-07-06  7:38 [PATCH net-next] net: Convert %pK back to %p Sebastian Andrzej Siewior
  2026-07-07  7:46 ` sashiko-bot
  2026-07-09 11:28 ` Petr Mladek
@ 2026-07-09 16:18 ` Kees Cook
  2 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2026-07-09 16:18 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-atm-general, linux-can, linux-sctp, netdev, David S. Miller,
	Eric Dumazet, Herbert Xu, Jakub Kicinski, Kuniyuki Iwashima,
	Marc Kleine-Budde, Marcelo Ricardo Leitner, Neal Cardwell,
	Oliver Hartkopp, Paolo Abeni, Remi Denis-Courmont, Simon Horman,
	Steffen Klassert, Willem de Bruijn, Xin Long, Petr Mladek,
	Thomas Weißschuh

On Mon, Jul 06, 2026 at 09:38:24AM +0200, Sebastian Andrzej Siewior wrote:
> This is a revert of commit 71338aa7d050c ("net: convert %p usage to
> %pK") which is from 2011. Back then the default behaviour for %p was to
> print the pointer. The %pK modifier was introduced to be able to control
> the behaviour of specific pointer output without changing the behaviour
> of %p for everyone. It was dedicated to avoid leaking pointers via
> /proc.

Given the policy on bare %p, and that there are so few in this list (15
files), how about review those that can just simply be removed or
switched to %pS, etc:
https://docs.kernel.org/process/deprecated.html#p-format-specifier

-- 
Kees Cook

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

end of thread, other threads:[~2026-07-09 16:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06  7:38 [PATCH net-next] net: Convert %pK back to %p Sebastian Andrzej Siewior
2026-07-07  7:46 ` sashiko-bot
2026-07-07  9:37   ` Sebastian Andrzej Siewior
2026-07-09 11:28 ` Petr Mladek
2026-07-09 16:18 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox