Skip to contentSkip to conversation

net: clear sk->sk_ino in sk_set_socket(sk, NULL)

PATCH Applied Eric Dumazet 3 participants 6 messages Sep 17, 2025 – Sep 18, 2025 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: clear sk->sk_ino in sk_set_socket(sk, NULL)

Andrei Vagin reported that blamed commit broke CRIU.

Indeed, while we want to keep sk_uid unchanged when a socket is cloned, we want to clear sk->sk_ino.

Otherwise, sock_diag might report multiple sockets sharing the same inode number.

Move the clearing part from sock_orphan() to sk_set_socket(sk, NULL), called both from sock_orphan() and sk_clone_lock().

---
 include/net/sock.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/net/sock.h +3 -2
index fb13322a11fcf75211ce3ee8925807e888374f70..2e14283c5be1adeddc024527bd10dbd8a97a54bf 100644
@@ -2061,6 +2061,9 @@ static inline void sk_set_socket(struct sock *sk, struct socket *sock)
 	if (sock) {
 		WRITE_ONCE(sk->sk_uid, SOCK_INODE(sock)->i_uid);
 		WRITE_ONCE(sk->sk_ino, SOCK_INODE(sock)->i_ino);
+	} else {
+		/* Note: sk_uid is unchanged. */
+		WRITE_ONCE(sk->sk_ino, 0);
 	}
 }
 
@@ -2082,8 +2085,6 @@ static inline void sock_orphan(struct sock *sk)
 	sock_set_flag(sk, SOCK_DEAD);
 	sk_set_socket(sk, NULL);
 	sk->sk_wq  = NULL;
-	/* Note: sk_uid is unchanged. */
-	WRITE_ONCE(sk->sk_ino, 0);
 	write_unlock_bh(&sk->sk_callback_lock);
 }
 
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Eric Dumazet

Andrei Vagin reported that blamed commit broke CRIU.

Indeed, while we want to keep sk_uid unchanged when a socket is cloned, we want to clear sk->sk_ino.

Otherwise, sock_diag might report multiple sockets sharing the same inode number.

Quoted 8 lines

Move the clearing part from sock_orphan() to sk_set_socket(sk, NULL), called both from sock_orphan() and sk_clone_lock().

I think we need to add Cc: [email protected].

Thanks,
Andrei

#2 lore raw
Quoted 14 lines · Andrei Vagin
Quoted 12 lines · Eric Dumazet

Andrei Vagin reported that blamed commit broke CRIU.

Indeed, while we want to keep sk_uid unchanged when a socket is cloned, we want to clear sk->sk_ino.

Otherwise, sock_diag might report multiple sockets sharing the same inode number.

Move the clearing part from sock_orphan() to sk_set_socket(sk, NULL), called both from sock_orphan() and sk_clone_lock().

Quoted 8 lines
Quoted 5 lines

I think we need to add Cc: [email protected].

I never do this. Note that the prior patch had no such CC.

A message that is not in the archive (sent off-list or not yet received): CAEWA0a4x4XMZKtpz_pNKruC4zwjETVxUuEMs2m_==Dpib_Jrqg@mail.gmail.com

#4 lore raw
Quoted 31 lines · Andrei Vagin

is

Quoted 22 lines · Eric Dumazet
Quoted 20 lines · Andrei Vagin
Quoted 17 lines · Eric Dumazet

Andrei Vagin reported that blamed commit broke CRIU.

Indeed, while we want to keep sk_uid unchanged when a socket is cloned, we want to clear sk->sk_ino.

Otherwise, sock_diag might report multiple sockets sharing the same inode number.

Move the clearing part from sock_orphan() to sk_set_socket(sk, NULL), called both from sock_orphan() and sk_clone_lock().

Quoted 4 lines
Quoted 2 lines

I think we need to add Cc: [email protected].

I never do this. Note that the prior patch had no such CC.

Quoted 7 lines

The original patch has been ported to the v6.16 kernels. According to the kernel documentation
(https://www.kernel.org/doc/html/v6.5/process/stable-kernel-rules.html),
adding Cc: [email protected] is required for automatic porting into stable trees. Without this tag, someone will likely need to manually request that this patch be ported. This is my understanding of how the stable branch process works, sorry if I missed something.

Andrei, I think I know pretty well what I am doing. You do not have to explain to me anything.

Thank you.

#5 lore raw
Quoted 41 lines · Eric Dumazet
Quoted 31 lines · Andrei Vagin

is

Quoted 22 lines · Eric Dumazet
Quoted 20 lines · Andrei Vagin
Quoted 17 lines · Eric Dumazet

Andrei Vagin reported that blamed commit broke CRIU.

Indeed, while we want to keep sk_uid unchanged when a socket is cloned, we want to clear sk->sk_ino.

Otherwise, sock_diag might report multiple sockets sharing the same inode number.

Move the clearing part from sock_orphan() to sk_set_socket(sk, NULL), called both from sock_orphan() and sk_clone_lock().

Quoted 4 lines
Quoted 2 lines

I think we need to add Cc: [email protected].

I never do this. Note that the prior patch had no such CC.

Quoted 7 lines

The original patch has been ported to the v6.16 kernels. According to the kernel documentation
(https://www.kernel.org/doc/html/v6.5/process/stable-kernel-rules.html),
adding Cc: [email protected] is required for automatic porting into stable trees. Without this tag, someone will likely need to manually request that this patch be ported. This is my understanding of how the stable branch process works, sorry if I missed something.

Quoted 2 lines

Andrei, I think I know pretty well what I am doing. You do not have to explain to me anything.

Eric, please don't misunderstand me. I want to get this patch into the stable kernels as soon as possible. I appreciate your help here.

Thanks again for the fix.

#6 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 17 Sep 2025 13:53:37 +0000 you wrote:

Andrei Vagin reported that blamed commit broke CRIU.

Indeed, while we want to keep sk_uid unchanged when a socket is cloned, we want to clear sk->sk_ino.

Otherwise, sock_diag might report multiple sockets sharing the same inode number.

[...]

Here is the summary with links:
- [net] net: clear sk->sk_ino in sk_set_socket(sk, NULL)

    https://git.kernel.org/netdev/net/c/87ebb628a5ac

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html