Article View: linux.kernel.netdev
Article #13675Re: [PATCH net 2/4] af_unix: Fix scm_stat.nr_fds leaks for OOB skb.
From: netdev-bot+sashiko
Date: Tue, 10 Nov 2026 06:38
Date: Tue, 10 Nov 2026 06:38
101 lines
11672 bytes
11672 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message for "af_unix: Fix scm_stat.nr_fds leaks for
OOB skb." gives the wrong reason for the leak.
Pre-existing issues:
- [Medium] unix_dgram_disconnected() (net/unix/af_unix.c:616) purges a
datagram socket's receive queue with skb_queue_purge_reason() andβ¦
--
af_unix: Fix scm_stat.nr_fds leaks for OOB skb.
This commit adds scm_stat_del() calls on the paths that free or skip an
OOB skb. Those paths are in unix_stream_recv_urg(), manage_oob() and
unix_stream_read_skb(). Without the calls, u->scm_stat.nr_fds stays
elevated after an OOB skb carrying SCM_RIGHTS is dropped.
> Because unix_destruct_scm() has no reference to the receiving socket when
> passed descriptors are not AF_UNIX sockets, u->scm_stat.nr_fds (reported
> as scm_fds in /proc/<pid>/fdinfo/<fd>) remains permanently elevated.
[Severity: Low]
Is this explanation accurate? It reads as if the leak only happens when
the passed descriptors are not AF_UNIX sockets.
The destructor path never decrements nr_fds for any fd type:
unix_destruct_scm()->unix_detach_fds()->unix_destroy_fpl()->unix_del_edges()
net/unix/garbage.c:unix_del_edges() {
...
if (!fpl->dead) {
receiver = fpl->edges[0].successor;
receiver->scm_stat.nr_unix_fds -= fpl->count_unix;
}
out:
WRITE_ONCE(fpl->user->unix_inflight, fpl->user->unix_inflight - fpl->count);
...
}
The destructor can reach the receiver through the AF_UNIX edges, but it
only updates nr_unix_fds and unix_inflight.
The only decrement of nr_fds is the atomic_sub() in scm_stat_del(). So
these OOB free paths leaked nr_fds for AF_UNIX descriptors too.
The oob_fdinfo selftest in this series sends AF_UNIX socket fds
(self->fd[inflight * 2]) over MSG_OOB. It expects scm_fds to go back to 0
only with this fix applied.
Could the commit message describe the cause as scm_stat_del() being the
only place nr_fds is decremented, whatever the fd type?
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index bfaab7c6d7203..44c0a81dd423a 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
[ ... ]
> @@ -2906,6 +2915,7 @@ static int unix_stream_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
> spin_unlock(&queue->lock);
> mutex_unlock(&u->iolock);
>
> + scm_stat_del(sk, skb);
> kfree_skb_reason(skb, SKB_DROP_REASON_UNIX_SKIP_OOB);
> return -EAGAIN;
> }
[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. Is
there a similar nr_fds leak in unix_dgram_disconnected()?
net/unix/af_unix.c:unix_dgram_disconnected() {
if (!skb_queue_empty(&sk->sk_receive_queue)) {
skb_queue_purge_reason(&sk->sk_receive_queue,
SKB_DROP_REASON_UNIX_DISCONNECT);
...
}
Each skb on that queue was counted by scm_stat_add() at send time. The
queue is purged without scm_stat_del(), and the socket stays in use. This
happens when unix_dgram_connect() gives it a new peer (or AF_UNSPEC), and
also from unix_dgram_sendmsg().
Sending SCM_RIGHTS to a connected SOCK_DGRAM socket and then calling
connect() on it before reading would leave scm_fds in fdinfo too high.
This is fixed later in the same series by "af_unix: Fix scm_stat.nr_fds
leak in unix_dgram_disconnected()". That patch dequeues each skb and calls
scm_stat_del() before kfree_skb_reason(), and the dgram_disconnect_fdinfo
selftest covers it.
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106051905.218638-1-sidchintamaneni%40gmail.com
Technical Details
Message-ID:
<179429269890.994134.2299928525127713908@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359915-linux-kernel-netdev=dewy.ruReferences:
<20261106051905.218638-3-sidchintamaneni@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359915-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 2/4] af_unix: Fix scm_stat.nr_fds leaks for OOB skb. Date: Tue, 10 Nov 2026 06:38:18 +0000 Organization: Usenet Network Message-ID: <179429269890.994134.2299928525127713908@kernel.org> References: <20261106051905.218638-3-sidchintamaneni@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="541592"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:SLq1NQQ56WQBALS0Zvjcv9UEdaw= sha256:LLHinJ/Jpxvr2h5M3QmL0ztQnDM4ioYRSkDxj20rcDE= sha1:xyR7ilo/NTHdtsdjjHCDC3sJuuk= sha256:FacgGLvTX0QyKYPFSyE/Gs0heVtGwXgUR+HSMEJgBzc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 333E0113A55; Tue, 10 Nov 2026 09:40:38 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qNIWzZqbTnhe; Tue, 10 Nov 2026 09:40:32 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359915-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 6464D113A4F; Tue, 10 Nov 2026 09:40:24 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 05BC3A7811; Tue, 10 Nov 2026 06:38:32 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794292711; b=PVkuqXUZDLn6XucKSlARJSAg60Si0BQgUDWONYa4RfSISGfRAz1gUUOgBm4CRwkxwTiY 8arkgG5p8hz3syOJe3n7x6V6y6UYVgr9qctC7r+SG5QSwSwVnGhBkZ8+K20TYx+z/1AN0 RQBMpo5N8B7p7NR5lhvcFMqv3QFYp6DQaQpuSgz8ovPR8u2GecczdvWmS7TuBW1dmpcr3 H05fAuYETcUDrlf7z2wRn00GPv/J/ae2SLeZWuqV+hEjAaoCkFDKyKQ5COunS1kknsQ5e 4wT+Joe684ukC0VZlyupImE/efEHwtDiERt6pO3KlMp7LT722DFd2su8OjoCckVzLxQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794292711; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=tb6492JbkmgtBmoAA1lWUlcjhbJx5wzf1aKynM8S9Rs=; b=YB3vt1qloEv/cimZnl1jiqn/4HCLNgD6tGH5qnvzJeONtuzSr25C6woOASIHkGl42qdL DQkFc4Fdkiybt+S1oipItYla+ghlrpWC+bvt/mgNz4zbyfIJeliswRGYZmjDcDPuwoGWg vNYQC+rSwWa7R9Tq0TQD0JQJgZkqELfnECNKSEjd0mlKtmW0Ydzubn2ZJ4bh47fUA6hB0 xA7clhGmEUAvNAUTZW4hjYlkk3byfgZEFRiQljP8J6pLgMe7hOeDGlDS+QF6xDiDP9+j0 1rKLHfb1vLoyfy+nICgJxINnf23ju8ffjImjJ698CWNNWA3NLL3e7soz17h2CHwegSA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NUepMDTX; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFB66606A326; Tue, 10 Nov 2026 06:38:31 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NUepMDTX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794292701; b=pAKnVn0LIEdrKx5uB4iNo6+yY5vZ4hOiV/9jryH+tdH/QZEpSk0VzJpWOrf/OY5d2VVo 1OA9MbFr1wd3Ydv7a7R0VBHBMnXnnG0uXOd4yFeE2VXHFdGreUDKVXvdHmTuWK5F1YBWf cKAbI2SBzFvhggnnYWwp4T6zxwAoK9PeIVmUzlqGo6F8N60eazO7HzYhgNOrlcIflMesP iMzNx9kXubP/E89fdUpxNkW0c0XbrkhQa2qz9f1RLeG14FBBtrJiZj7W1SzfJNEbVVZ3c F3+V2AD6LcuI+WiQmlkaImOI+GXLUqSa1GZcDrFeM13sbuX/5qthjPU9tZGOv8mQncA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794292701; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=tb6492JbkmgtBmoAA1lWUlcjhbJx5wzf1aKynM8S9Rs=; b=2teSafqQRAcCU68dzGT1zoD4+3/0VMcKM6/iRpuLZ9ChLasw5Ox5nf1FmPAB+OtAURPO q3WOd4FTfwqRycvKZBOkVe5FUs7eVpsGvJaMSv0Vyu9rZ6djagNab+ASw+SICxYtlWUIS Bj+IW2f4AdpaG5fIKpPKmolmiRc3vAeHYpn+k8ITgURadJoXc/hPv7wiS+gbR41TG+N9M nJzHn+HMcoEIG+dRzWNiiUfbioNwtOcdNTv+mYl93i5lAcjlF2aa27hK50xQXgqJz3YJF AD7wuOv2ZonybAtUxQaO+QcmUerhZhjnQUylbPx+FRiXfCAmt+wNPobrTvOv0NSzg5w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NUepMDTX; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 935D5606A334; Tue, 10 Nov 2026 06:38:20 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CCDB1F008A2; Tue, 10 Nov 2026 06:38:19 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794292700; bh=tb6492JbkmgtBmoAA1lWUlcjhbJx5wzf1aKynM8S9Rs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NUepMDTXMV1qSqxVZiGi7dTMF76kI6beGLfpgFoQm994HjHyQHhEo0pjgyNb2ThHM wXgUiUBUSxufsqt5BE8SrGxyRB43bLWCD0FDyJm0lgsh/IwTQBWro2gI7HS31ZqKoM h3PC3WQLXQkvmm9ZXljjtnJDGhTkoseoweHyUbq7RwzhATQ0OBH8Ko1QTaQHUK4QOY uuAucLUaaKv5yDEYu/APqwUDEbTZlFfg1rtJPmPQjM1jpNf0WZPKfWw0UEHhLdFtja 34ytQjEC+WGd2G5jydmujjZnBa1E5CoqJjb1AApTCWEJYMTQE5m2mZUYNZGT8mVCTw Rq1qCSMykbTWg== X-Cc: kuniyu@google.com, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, willemb@google.com, jannh@google.com, tkhai@ya.ru, apais@microsoft.com, rlmenge@gmail.com, hargar@linux.microsoft.com, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261106051905.218638-3-sidchintamaneni@gmail.com> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list