]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
af_unix: Define locking order for U_RECVQ_LOCK_EMBRYO in unix_collect_skb().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Thu, 20 Jun 2024 20:56:20 +0000 (13:56 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 09:00:11 +0000 (11:00 +0200)
commit0919388ac44f8a0d7e448d8f85b075417ce75281
tree08e74500f798b0e783bcfc878823c131a0af5404
parentfd3af69c14ed0611910ecae8d60dbb084af51a25
af_unix: Define locking order for U_RECVQ_LOCK_EMBRYO in unix_collect_skb().

[ Upstream commit 8647ece4814f3bfdb5f7a8e19f882c9b89299a07 ]

While GC is cleaning up cyclic references by SCM_RIGHTS,
unix_collect_skb() collects skb in the socket's recvq.

If the socket is TCP_LISTEN, we need to collect skb in the
embryo's queue.  Then, both the listener's recvq lock and
the embroy's one are held.

The locking is always done in the listener -> embryo order.

Let's define it as unix_recvq_lock_cmp_fn() instead of using
spin_lock_nested().

Note that the reverse order is defined for consistency.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Stable-dep-of: 32ca245464e1 ("af_unix: Don't leave consecutive consumed OOB skbs.")
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/unix/af_unix.c
net/unix/garbage.c