From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Nam Cao <namcao@linutronix.de>
Cc: Kuniyuki Iwashima <kuniyu@google.com>,
sashiko-reviews@lists.linux.dev,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH 1/2] af_unix: Do not wait for garbage collector in sendmsg()
Date: Tue, 7 Jul 2026 13:42:25 +0200 [thread overview]
Message-ID: <20260707114225.4oj9SF_0@linutronix.de> (raw)
In-Reply-To: <87wlvbmgtv.fsf@yellow.woof>
On 2026-07-04 08:03:56 [+0200], Nam Cao wrote:
> Kuniyuki Iwashima <kuniyu@google.com> writes:
> > your patch makes it much easier to abuse.
> > UNIX_INFLIGHT_SANE_USER is usually much smaller than
> > RLIMIT_NOFILE.
> >
> > unix_schedule_gc() in sendmsg() is to self-regulate malicious users,
> > otherwise GC relies on unrelated AF_UNIX socket's close() and could
> > be triggered too late since GC is system-wide.
>
> About the abuse, the scenario where inflight sockets bypass
> UNIX_INFLIGHT_SANE_USER and delay GC until an unrelated AF_UNIX socket
> closes actually exists today.
We don't bypass the limit for an ordinary user. That one gets blocked in
too_many_unix_fds(). But for the CAP_SYS_RESOURCE + CAP_SYS_ADMIN it is
a different story.
In that case we cross the UNIX_INFLIGHT_SANE_USER and schedule the GC,
it is not delayed. The worker is triggered regularity and the thread
waits for its completion it is just the GC worker does not clean up
anything so it continues to increase. The only thing that actually
limits the sender is if it runs out of socket memory and needs to wait.
So it kind of works for a single thread.
…
> To address this properly, we can schedule the GC at task exit. I can
> include that patch in my series, if that sounds good to you.
task exit or closing the socket?
Either way, in your PoC it hardly makes any sense to schedule the worker
over and over and wait for it since it does not do anything. Sure it is
the system as a whole so triggering might make sense but I'm not sure
about waiting for its completion.
Side note: gc_in_progress is redundant since you can't schedule a worker
twice and work_pending(&unix_gc_work) would provide the same
information. The only difference is that you avoid scheduling the worker
while it is running but I don't think this is a problem.
> Nam
Sebastian
next prev parent reply other threads:[~2026-07-07 11:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 16:35 [PATCH 0/2] af_unix: Fix priority inversion issue Nam Cao
2026-07-01 16:35 ` [PATCH 1/2] af_unix: Do not wait for garbage collector in sendmsg() Nam Cao
2026-07-02 3:27 ` Kuniyuki Iwashima
2026-07-02 3:56 ` Nam Cao
2026-07-02 16:36 ` sashiko-bot
2026-07-03 5:53 ` Nam Cao
2026-07-03 6:25 ` Kuniyuki Iwashima
2026-07-04 6:03 ` Nam Cao
2026-07-07 11:42 ` Sebastian Andrzej Siewior [this message]
2026-07-01 16:35 ` [PATCH 2/2] af_unix: Clean up unix_schedule_gc() Nam Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260707114225.4oj9SF_0@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=namcao@linutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.