Unverified Commit 0fe27e59 authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner
Browse files

net: change sock.sk_ino and sock_i_ino() to u64



inode->i_ino is being converted to a u64. sock.sk_ino (which caches the
inode number) must also be widened to avoid truncation on 32-bit
architectures where unsigned long is only 32 bits.

Change sk_ino from unsigned long to u64, and update the return type
of sock_i_ino() to match. Fix all format strings that print the
result of sock_i_ino() (%lu -> %llu), and widen the intermediate
variables and function parameters in the diag modules that were
using int to hold the inode number.

Note that the UAPI socket diag structures (inet_diag_msg.idiag_inode,
unix_diag_msg.udiag_ino, etc.) are all __u32 and cannot be changed
without breaking the ABI. The assignments to those fields will
silently truncate, which is the existing behavior.

Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> # for net/can
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260304-iino-u64-v3-3-2257ad83d372@kernel.org


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 125dfa21
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -537,7 +537,7 @@ struct sock {
	rwlock_t		sk_callback_lock;
	u32			sk_ack_backlog;
	u32			sk_max_ack_backlog;
	unsigned long		sk_ino;
	u64			sk_ino;
	spinlock_t		sk_peer_lock;
	int			sk_bind_phc;
	struct pid		*sk_peer_pid;
@@ -2140,7 +2140,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
	write_unlock_bh(&sk->sk_callback_lock);
}

static inline unsigned long sock_i_ino(const struct sock *sk)
static inline u64 sock_i_ino(const struct sock *sk)
{
	/* Paired with WRITE_ONCE() in sock_graft() and sock_orphan() */
	return READ_ONCE(sk->sk_ino);
+1 −1
Original line number Diff line number Diff line
@@ -1986,7 +1986,7 @@ static int ax25_info_show(struct seq_file *seq, void *v)
		   ax25->paclen);

	if (ax25->sk != NULL) {
		seq_printf(seq, " %d %d %lu\n",
		seq_printf(seq, " %d %d %llu\n",
			   sk_wmem_alloc_get(ax25->sk),
			   sk_rmem_alloc_get(ax25->sk),
			   sock_i_ino(ax25->sk));
+2 −2
Original line number Diff line number Diff line
@@ -817,14 +817,14 @@ static int bt_seq_show(struct seq_file *seq, void *v)
		struct bt_sock *bt = bt_sk(sk);

		seq_printf(seq,
			   "%pK %-6d %-6u %-6u %-6u %-6lu %-6lu",
			   "%pK %-6d %-6u %-6u %-6u %-6llu %-6llu",
			   sk,
			   refcount_read(&sk->sk_refcnt),
			   sk_rmem_alloc_get(sk),
			   sk_wmem_alloc_get(sk),
			   from_kuid(seq_user_ns(seq), sk_uid(sk)),
			   sock_i_ino(sk),
			   bt->parent ? sock_i_ino(bt->parent) : 0LU);
			   bt->parent ? sock_i_ino(bt->parent) : 0ULL);

		if (l->custom_seq_show) {
			seq_putc(seq, ' ');
+1 −1
Original line number Diff line number Diff line
@@ -1712,7 +1712,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr_unsized *uaddr, int
#if IS_ENABLED(CONFIG_PROC_FS)
	if (net->can.bcmproc_dir) {
		/* unique socket address as filename */
		sprintf(bo->procname, "%lu", sock_i_ino(sk));
		sprintf(bo->procname, "%llu", sock_i_ino(sk));
		bo->bcm_proc_read = proc_create_net_single(bo->procname, 0644,
						     net->can.bcmproc_dir,
						     bcm_proc_show, sk);
+1 −1
Original line number Diff line number Diff line
@@ -1111,7 +1111,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 %lu %d %pK %u",
		" %02X %08X:%08X %02X:%08lX %08X %5u %8d %llu %d %pK %u",
		bucket, src, srcp, dest, destp, sp->sk_state,
		sk_wmem_alloc_get(sp),
		sk_rmem_alloc_get(sp),
Loading