[PATCH net v3 0/2] af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected()
From: Siddharth Chintamaneni
Date: Sat Nov 14 2026 - 11:27:06 EST
This series fixes a u->scm_stat.nr_fds accounting leak in
unix_dgram_disconnected() when purging queued skbs from
sk->sk_receive_queue on disconnect, along with a selftest:
- Patch 1 splices sk->sk_receive_queue onto a local list in
unix_dgram_disconnected() and calls scm_stat_del() before freeing each
purged skb.
- Patch 2 adds dgram_disconnect_fdinfo to scm_rights.c verifying scm_fds
in /proc/self/fdinfo/<fd> across connect(AF_UNSPEC) and dead-peer
send() disconnects.
Changes in v3:
- Drop unnecessary count_sockets() and sleep(1) calls in
TEST(dgram_disconnect_fdinfo).
- Link to v2: https://lore.kernel.org/all/20261111225148.88506-1-sidchintamaneni@xxxxxxxxx/
Changes in v2:
- Drop MSG_OOB patches and tests per Kuniyuki Iwashima.
- Splice sk->sk_receive_queue onto a local list under the queue lock
before freeing skbs so concurrent senders cannot extend the drain loop.
- Make dgram_disconnect_fdinfo a standalone TEST() instead of running
no-op fixture variants, and also test dead-peer send() disconnect.
- Link to v1: https://lore.kernel.org/all/20261106051905.218638-1-sidchintamaneni@xxxxxxxxx/
Siddharth Chintamaneni (2):
af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected().
selftest: af_unix: Test scm_fds on dgram disconnect.
net/unix/af_unix.c | 59 +++++++++------
.../selftests/net/af_unix/scm_rights.c | 75 +++++++++++++++++++
2 files changed, 110 insertions(+), 24 deletions(-)
--
2.43.0