[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iJOHzk+Sj+3c2PRywQaOMrqpxyodeSbkZ4++5E9xvnTpA@mail.gmail.com>
Date: Mon, 15 Sep 2025 11:51:06 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Andrei Vagin <avagin@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>, netdev@...r.kernel.org,
eric.dumazet@...il.com, syzbot+50603c05bbdf4dfdaffa@...kaller.appspotmail.com,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>, Kuniyuki Iwashima <kuniyu@...gle.com>
Subject: Re: [PATCH net] net: lockless sock_i_ino()
On Mon, Sep 15, 2025 at 11:16 AM Andrei Vagin <avagin@...gle.com> wrote:
>
> On Tue, Sep 02, 2025 at 06:36:03PM +0000, Eric Dumazet wrote:
> > @@ -2056,6 +2058,10 @@ static inline int sk_rx_queue_get(const struct sock *sk)
> > static inline void sk_set_socket(struct sock *sk, struct socket *sock)
> > {
> > sk->sk_socket = sock;
> > + if (sock) {
> > + WRITE_ONCE(sk->sk_uid, SOCK_INODE(sock)->i_uid);
> > + WRITE_ONCE(sk->sk_ino, SOCK_INODE(sock)->i_ino);
> > + }
>
> Hi Eric.
>
> This change breaks CRIU [1]. The issue is that socket_diag reports two
> sockets with the same inode number. It seems inet_csk_clone_lock copies
> sk->sk_ino to child sockets, but sk_set_socket doesn’t reset it to zero
> when sock is NULL.
Hi Andrei, thanks for the report.
Could you test this patch ?
diff --git a/include/net/sock.h b/include/net/sock.h
index 0fd465935334160eeda7c1ea608f5d6161f02cb1..36e11b2afb223bf18ff0596d634e885cca549d0f
100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2063,6 +2063,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);
}
}
@@ -2084,8 +2087,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);
}
Powered by blists - more mailing lists