af_unix: Fix inq_len and scm_stat.nr_fds accounting leaks
Subsystems (4)
cover af_unix: Fix inq_len and scm_stat.nr_fds accounting leaks
This series fixes receive-queue accounting leaks of u->inq_len and u->scm_stat.nr_fds in AF_UNIX sockets, along with selftests:
- Patch 1 fixes a u->inq_len leak in manage_oob() when an unconsumed out-of-band (MSG_OOB) skb is skipped and dropped during a normal read.
- Patch 2 fixes u->scm_stat.nr_fds leaks when an OOB skb is skipped or freed in manage_oob(), unix_stream_recv_urg(), and unix_stream_read_skb().
- Patch 3 fixes a u->scm_stat.nr_fds leak in unix_dgram_disconnected() when purging queued skbs from sk->sk_receive_queue on disconnect.
- Patch 4 adds SIOCINQ and scm_fds (/proc/self/fdinfo/<fd>) checks to the msg_oob and scm_rights selftests.
Siddharth Chintamaneni (4):
af_unix: Fix inq_len leak when skipping unread OOB skb.
af_unix: Fix scm_stat.nr_fds leaks for OOB skb.
af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected().
selftest: af_unix: Test SIOCINQ and scm_fds with OOB and dgram
disconnect.
net/unix/af_unix.c | 69 ++++++----- tools/testing/selftests/net/af_unix/msg_oob.c | 12 +- .../selftests/net/af_unix/scm_rights.c | 108 ++++++++++++++++++ 3 files changed, 161 insertions(+), 28 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 af_unix: Fix inq_len leak when skipping unread OOB skb.
When queue_oob() enqueues an out-of-band skb onto a stream socket's receive queue, it increments u->inq_len by 1 for the OOB byte.
If !sock_flag(sk, SOCK_URGINLINE) and the OOB byte has not been consumed via MSG_OOB, a subsequent normal read in manage_oob() unlinks the unconsumed u->oob_skb from sk_receive_queue and drops it via kfree_skb_reason(unread_skb, SKB_DROP_REASON_UNIX_SKIP_OOB), but fails to decrement u->inq_len.
As a result, unix_inq_len() (reported via ioctl(SIOCINQ), SCM_INQ, and sock_diag) remains permanently elevated by 1 for each skipped OOB skb.
Decrement u->inq_len under sk_receive_queue.lock when unlinking unread_skb in manage_oob().
--- net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+)
net/unix/af_unix.c +1 -0
@@ -2853,6 +2853,7 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sk_buff **last,WRITE_ONCE (u->oob_skb,NULL );if (!sock_flag (sk,SOCK_URGINLINE )) { +WRITE_ONCE (u->inq_len, u->inq_len -1 );__skb_unlink (skb, &sk->sk_receive_queue); unread_skb = skb; skb =skb_peek (&sk->sk_receive_queue);
Signature · 1 line
2.43.0
PATCH 2/4 af_unix: Fix scm_stat.nr_fds leaks for OOB skb.
In reply to Siddharth ChintamaneniWhen queue_oob() enqueues an out-of-band skb carrying SCM_RIGHTS file descriptors, it accounts the inflight descriptors in u->scm_stat.nr_fds via scm_stat_add().
However, the paths that later free or skip an OOB skb do not call scm_stat_del():
1. In manage_oob(), when !sock_flag(sk, SOCK_URGINLINE) and an unconsumed u->oob_skb is unlinked as unread_skb and dropped via kfree_skb_reason().
2. In manage_oob(), when a consumed OOB skb (read_skb) is unlinked and freed via consume_skb().
3. In unix_stream_recv_urg(), when a consecutive MSG_OOB read unlinks and frees a previously consumed OOB skb (read_skb).
4. In unix_stream_read_skb() (SOCKMAP), when skb == u->oob_skb, the skb is unlinked and dropped via kfree_skb_reason() before reaching unix_orphan_scm().
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.
Call scm_stat_del() before freeing read_skb or unread_skb in unix_stream_recv_urg(), manage_oob(), and unix_stream_read_skb().
--- net/unix/af_unix.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
net/unix/af_unix.c +13 -3
@@ -2807,7 +2807,10 @@ static int unix_stream_recv_urg(struct unix_stream_read_state *state)mutex_unlock (&u->iolock); -consume_skb (read_skb); +if (read_skb) { +scm_stat_del (sk, read_skb); +consume_skb (read_skb); + }if (chunk <0 )return -EFAULT ;
@@ -2867,8 +2870,14 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sk_buff **last, unlock:spin_unlock (&sk->sk_receive_queue.lock); -consume_skb (read_skb); -kfree_skb_reason (unread_skb,SKB_DROP_REASON_UNIX_SKIP_OOB ); +if (read_skb) { +scm_stat_del (sk, read_skb); +consume_skb (read_skb); + } +if (unread_skb) { +scm_stat_del (sk, unread_skb); +kfree_skb_reason (unread_skb,SKB_DROP_REASON_UNIX_SKIP_OOB ); + }return skb; }
@@ -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 ; }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net 2/4] af_unix: Fix scm_stat.nr_fds leaks for OOB skb.
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…
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.
Quoted 3 lines
Because
unix_destruct_scm()has no reference to the receiving socket when passed descriptors are notAF_UNIXsockets,u->scm_stat.nr_fds(reported asscm_fdsin /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?
Quoted 4 lines
net/unix/af_unix.c +0
-0
[ ... ]
net/unix/af_unix.c static int unix_stream_read_skb(struct sock *sk, skb_read_actor_t recv_actor) · line 2921
Quoted 8 lines
net/unix/af_unix.c +1
-0@@ -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.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106051905.218638-1-sidchintamaneni%40gmail.com
PATCH 3/4 af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected().
In reply to Siddharth ChintamaneniWhen a connected SOCK_DGRAM socket disconnects (e.g. via connect() with AF_UNSPEC), reconnects to a different peer, or observes a dead peer in unix_dgram_sendmsg(), unix_dgram_disconnected() purges all unread datagrams from sk->sk_receive_queue via skb_queue_purge_reason().
Because skb_queue_purge_reason() frees each skb without calling scm_stat_del(sk, skb), any SCM_RIGHTS file descriptors attached to the purged skbs remain permanently accounted in u->scm_stat.nr_fds (reported as scm_fds in /proc/<pid>/fdinfo/<fd>) for the remaining lifetime of the socket.
Move scm_stat_add() and scm_stat_del() above unix_dgram_disconnected() and dequeue each skb in unix_dgram_disconnected() so scm_stat_del() is called before kfree_skb_reason().
--- net/unix/af_unix.c | 52 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 24 deletions(-)
net/unix/af_unix.c +28 -24
@@ -609,6 +609,28 @@ static void unix_write_space(struct sock *sk)rcu_read_unlock (); } +static void scm_stat_add (struct sock *sk,struct sk_buff *skb) +{ +struct scm_fp_list *fp =UNIXCB (skb).fp; +struct unix_sock *u =unix_sk (sk); + +if (unlikely (fp && fp->count)) { +atomic_add (fp->count, &u->scm_stat.nr_fds); +unix_add_edges (fp, u); + } +} + +static void scm_stat_del (struct sock *sk,struct sk_buff *skb) +{ +struct scm_fp_list *fp =UNIXCB (skb).fp; +struct unix_sock *u =unix_sk (sk); + +if (unlikely (fp && fp->count)) { +atomic_sub (fp->count, &u->scm_stat.nr_fds); +unix_del_edges (fp); + } +} +/* When dgram socket disconnects (or changes its peer), we clear its receive * queue of packets arrived from previous peer. First, it allows to do * flow control based only on wmem_alloc; second, sk connected to peer
@@ -616,8 +638,12 @@ static void unix_write_space(struct sock *sk)static void unix_dgram_disconnected (struct sock *sk,struct sock *other) {if (!skb_queue_empty (&sk->sk_receive_queue)) { -skb_queue_purge_reason (&sk->sk_receive_queue, -SKB_DROP_REASON_UNIX_DISCONNECT ); +struct sk_buff *skb; + +while ((skb =skb_dequeue (&sk->sk_receive_queue)) !=NULL ) { +scm_stat_del (sk, skb); +kfree_skb_reason (skb,SKB_DROP_REASON_UNIX_DISCONNECT ); + }wake_up_interruptible_all (&unix_sk (sk)->peer_wait);
@@ -2058,28 +2084,6 @@ static bool unix_skb_scm_eq(const struct sock *sk, struct sk_buff *skb,unix_secdata_eq (scm, skb); } -static void scm_stat_add (struct sock *sk,struct sk_buff *skb) -{ -struct scm_fp_list *fp =UNIXCB (skb).fp; -struct unix_sock *u =unix_sk (sk); - -if (unlikely (fp && fp->count)) { -atomic_add (fp->count, &u->scm_stat.nr_fds); -unix_add_edges (fp, u); - } -} - -static void scm_stat_del (struct sock *sk,struct sk_buff *skb) -{ -struct scm_fp_list *fp =UNIXCB (skb).fp; -struct unix_sock *u =unix_sk (sk); - -if (unlikely (fp && fp->count)) { -atomic_sub (fp->count, &u->scm_stat.nr_fds); -unix_del_edges (fp); - } -} -static void unix_orphan_scm (struct sock *sk,struct sk_buff *skb) {scm_stat_del (sk, skb);
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net 3/4] af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected().
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] In net/unix/af_unix.c, unix_dgram_disconnected() used to free a fixed snapshot of the receive queue.
--
af_unix: Fix scm_stat.nr_fds leak in unix_dgram_disconnected().
This patch changes unix_dgram_disconnected() so that it dequeues each skb from sk->sk_receive_queue, calls scm_stat_del(), and only then frees the skb. Before this, skb_queue_purge_reason() freed the skbs without updating the counter, so u->scm_stat.nr_fds stayed too high after a disconnect. scm_stat_add() and scm_stat_del() move above unix_dgram_disconnected() so they can be called from there.
Quoted 4 lines
net/unix/af_unix.c +0
-0
[ ... ]
net/unix/af_unix.c static void unix_write_space(struct sock *sk) · line 646
Quoted 12 lines
net/unix/af_unix.c +6
-2@@ -616,8 +638,12 @@ static void unix_write_space(struct sock *sk)static void unix_dgram_disconnected (struct sock *sk,struct sock *other) {if (!skb_queue_empty (&sk->sk_receive_queue)) { -skb_queue_purge_reason (&sk->sk_receive_queue, -SKB_DROP_REASON_UNIX_DISCONNECT ); +struct sk_buff *skb; + +while ((skb =skb_dequeue (&sk->sk_receive_queue)) !=NULL ) { +scm_stat_del (sk, skb); +kfree_skb_reason (skb,SKB_DROP_REASON_UNIX_DISCONNECT ); + }
[Severity: Medium]
Can this loop keep running while other senders refill the queue?
skb_queue_purge_reason() took a snapshot of the queue. It took the lock once, spliced everything onto a private list, and freed only that list:
net/core/skbuff.c:skb_queue_purge_reason() {
...
spin_lock_irqsave(&list->lock, flags);
skb_queue_splice_init(list, &tmp);
spin_unlock_irqrestore(&list->lock, flags);
__skb_queue_purge_reason(&tmp, reason);
}The new loop drains the live queue until it happens to be empty. It also takes and drops the irq-disabling queue lock once per skb.
Both callers have already published the new peer state and dropped the unix state locks before they call this. In unix_dgram_connect():
unix_peer(sk) = other;
...
unix_state_double_unlock(sk, other);
if (other != old_peer) {
unix_dgram_disconnected(sk, old_peer);On the dead-peer path in unix_dgram_sendmsg():
unix_peer(sk) = NULL; unix_dgram_peer_wake_disconnect_wakeup(sk, other); WRITE_ONCE(sk->sk_state, TCP_CLOSE); unix_state_unlock(sk); unix_dgram_disconnected(sk, other);
Quoted 1 line
From then on the new peer can send to sk. If the peer is now NULL
(AF_UNSPEC or the dead-peer case), any socket that can reach sk's bound address can send to it as well. Those senders reach this code in unix_dgram_sendmsg() while the loop is still running:
scm_stat_add(other, skb); skb_queue_tail(&other->sk_receive_queue, skb);
The receiver-side flow control does not hold them back:
if (other != sk &&
unlikely(unix_peer(other) != sk &&
unix_recvq_full_lockless(other))) {This check is skipped completely when the sender is sk's new peer. For other senders it only applies once the queue is above sk_max_ack_backlog, and the loop keeps the queue below that.
If several CPUs keep sending, connect() or sendmsg() could stay in this loop with no fixed bound and no cond_resched(). Could that cause soft lockups on non-preemptible kernels?
Datagrams that the new peer queues after the peer change would also be dropped as SKB_DROP_REASON_UNIX_DISCONNECT for as long as the loop runs. Before this patch, that window ended at the single splice.
For reference, the old skb_queue_purge_reason() used the same dequeue-until-empty form before commit d86e5fbd4c96 changed it to splice.
Would it work to keep the splice? The queue could be spliced into a local sk_buff_head under sk->sk_receive_queue.lock, and then the local list walked with scm_stat_del() and kfree_skb_reason() on each skb. That keeps the new nr_fds accounting and bounds the work at the time of the splice.
Quoted 3 lines
wake_up_interruptible_all(&unix_sk(sk)->peer_wait);
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106051905.218638-1-sidchintamaneni%40gmail.com
PATCH 4/4 selftest: af_unix: Test SIOCINQ and scm_fds with OOB and dgram disconnect.
In reply to Siddharth ChintamaneniVerify in msg_oob's __resetpair() that ioctl(SIOCINQ) reports 0 unread bytes after draining the stream receive queue, and add oob_fdinfo and dgram_disconnect_fdinfo tests in scm_rights.c verifying that /proc/self/fdinfo/<fd> (scm_fds) returns to 0 when OOB skbs carrying SCM_RIGHTS are skipped or freed and when a dgram socket disconnects with queued SCM_RIGHTS skbs.
--- tools/testing/selftests/net/af_unix/msg_oob.c | 12 +- .../selftests/net/af_unix/scm_rights.c | 108 ++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-)
tools/testing/selftests/net/af_unix/msg_oob.c +11 -1
@@ -5,6 +5,7 @@#include <string.h> #include <unistd.h> +#include <linux/sockios.h> #include <netinet/in.h> #include <sys/epoll.h> #include <sys/ioctl.h>
@@ -336,8 +337,17 @@ static void __resetpair(struct __test_metadata *_metadata, {int i; -for (i =0 ; i <2 ; i++) +for (i =0 ; i <2 ; i++) { +if (!reset) { +int inq, ret; + + ret =ioctl (self->fd[i *2 +1 ],SIOCINQ , &inq); +ASSERT_EQ (ret,0 ); +ASSERT_EQ (inq,0 ); + } +close (self->fd[i *2 +1 ]); + }__recvpair (_metadata, self,"" , reset ? -ECONNRESET :0 ,1 , variant->peek ?MSG_PEEK :0 , true);
tools/testing/selftests/net/af_unix/scm_rights.c +108 -0
118 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net 4/4] selftest: af_unix: Test SIOCINQ and scm_fds with OOB and dgram disconnect.
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…
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] Two new tests in tools/testing/selftests/net/af_unix/scm_rights.c, oob_fdinfo() and…
--
selftest: af_unix: Test SIOCINQ and scm_fds with OOB and dgram disconnect.
This commit adds a SIOCINQ check to msg_oob's __resetpair() so that the drained stream receive queue reports 0 unread bytes. It also adds oob_fdinfo and dgram_disconnect_fdinfo tests to scm_rights.c. These check that scm_fds in /proc/self/fdinfo/<fd> goes back to 0 when OOB skbs carrying SCM_RIGHTS are skipped or freed, and when a dgram socket with queued SCM_RIGHTS skbs disconnects.
Quoted 4 lines
tools/testing/selftests/net/af_unix/scm_rights.c +0
-0
[ ... ]
tools/testing/selftests/net/af_unix/scm_rights.c TEST_F(scm_rights, mixed_lowpoint) · line 434
Quoted 11 lines
tools/testing/selftests/net/af_unix/scm_rights.c +7
-0@@ -395,4 +425,82 @@ TEST_F(scm_rights, mixed_lowpoint)close_sockets (6 ); } +TEST_F(scm_rights, oob_fdinfo) +{ +int recv_fd, ret; +char buf[2 ]; + +if (!(variant->flags &MSG_OOB ) || variant->disabled) +return ;
[Severity: Low]
Should these early returns use SKIP() instead?
In kselftest_harness, a plain return from a TEST_F body counts as a pass. The scm_rights fixture has 10 variants, and oob_fdinfo() only does real work on stream_oob and stream_listener_oob. The other 8 variants report "ok" even though nothing was checked.
dgram_disconnect_fdinfo() later in this patch has the same pattern:
if (variant->type != SOCK_DGRAM || variant->disabled) return;
It only runs on dgram and reports "ok" on the other 9 variants. That makes 17 TAP results that show as passes rather than "# SKIP".
The sibling test scm_rights_denial_lsm.c already uses this form:
SKIP(return, "requires root");
Also, FIXTURE_SETUP and FIXTURE_TEARDOWN still run for these no-op cases. FIXTURE_TEARDOWN(scm_rights) does this:
if (variant->disabled) return; sleep(1);
So the no-op runs on non-disabled variants add about 7 seconds of runtime. That is 3 for oob_fdinfo (dgram, stream, stream_listener) and 4 for dgram_disconnect_fdinfo (stream, stream_oob, stream_listener, stream_listener_oob).
Quoted 9 lines
tools/testing/selftests/net/af_unix/scm_rights.c +9
-0+ +create_sockets (2 ); + +if (variant->test_listener) { + recv_fd =accept (self->fd[0 ],NULL ,NULL ); +ASSERT_LE (0 , recv_fd); + }else { + recv_fd = self->fd[0 ]; + }
[ ... ]
Quoted 9 lines
tools/testing/selftests/net/af_unix/scm_rights.c +9
-0+TEST_F(scm_rights, dgram_disconnect_fdinfo) +{ +struct sockaddr addr = { + .sa_family =AF_UNSPEC , + }; +int ret; + +if (variant->type !=SOCK_DGRAM || variant->disabled) +return ;
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106051905.218638-1-sidchintamaneni%40gmail.com
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Kuniyuki Iwashima
maintainerQuoted 12 lines · Siddharth Chintamaneni
This series fixes receive-queue accounting leaks of
u->inq_lenandu->scm_stat.nr_fdsinAF_UNIXsockets, along with selftests:- Patch 1 fixes a
u->inq_lenleak inmanage_oob()when an unconsumed out-of-band (MSG_OOB) skb is skipped and dropped during a normal read.
- Patch 2 fixesu->scm_stat.nr_fdsleaks when an OOB skb is skipped or freed inmanage_oob(),unix_stream_recv_urg(), andunix_stream_read_skb().
- Patch 3 fixes au->scm_stat.nr_fdsleak inunix_dgram_disconnected()when purging queued skbs fromsk->sk_receive_queueon disconnect.
- Patch 4 adds SIOCINQ andscm_fds(/proc/self/fdinfo/<fd>) checks to themsg_oobandscm_rightsselftests.
I planed to drop MSG_OOB support in this cycle.
Could you repost without OOB changes ?
Quoted 16 lines
Siddharth Chintamaneni (4):
af_unix: Fixinq_lenleak when skipping unread OOB skb.
af_unix: Fix scm_stat.nr_fds leaks for OOB skb.
af_unix: Fix scm_stat.nr_fds leak inunix_dgram_disconnected().
selftest:af_unix: Test SIOCINQ andscm_fdswith OOB and dgram
disconnect.net/unix/af_unix.c | 69 ++++++----- tools/testing/selftests/net/af_unix/msg_oob.c | 12 +- .../selftests/net/af_unix/scm_rights.c | 108 ++++++++++++++++++ 3 files changed, 161 insertions(+), 28 deletions(-)Signature · 1 line
2.43.0