Skip to content

af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected()

Siddharth Chintamaneni linux-kselftest lkml netdev 2 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 1 replyApplied 2/2
  2. v22 patches 3 repliesSuperseded

Changes in v3 from the cover letter

- Drop unnecessary count_sockets() and sleep(1) calls in TEST(dgram_disconnect_fdinfo).
- Link to v2: https://lore.kernel.org/all/[email protected]/

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected().net/unix/af_unix.c+35 -240 repliesApplied
2/2selftest: af_unix: Test scm_fds on dgram disconnect.tools/testing/selftests/net/af_unix/scm_rights.c+75 -01 replyApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchKuniyuki Iwashima
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH net v3 0/2] af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected()

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/[email protected]/

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/[email protected]/

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(-)
Signature · 1 line
2.43.0