From: sashiko-bot@kernel.org
To: "Nam Cao" <namcao@linutronix.de>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH net-next v3 2/3] af_unix: Do not wait for garbage collector in sendmsg()
Date: Thu, 23 Jul 2026 09:31:53 +0000 [thread overview]
Message-ID: <20260723093154.004131F000E9@smtp.kernel.org> (raw)
In-Reply-To: <f005544705b193975c6a108fa733abc3d0e01755.1784712370.git.namcao@linutronix.de>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Removing `unix_schedule_gc()` from `sendmsg()` prevents the AF_UNIX garbage collector from being proactively triggered for isolated cyclic references, leading to spurious -ETOOMANYREFS failures and indefinite resource leaks.
- [Low] The `user` parameter and its associated conditional logic in `unix_schedule_gc()` are now dead code.
--
--- Patch [2]: [PATCH net-next v3 2/3] af_unix: Do not wait for garbage collector in sendmsg() ---
commit e95749602b1bd36f1394eab73582d88874294091
Author: Nam Cao <namcao@linutronix.de>
af_unix: Do not wait for garbage collector in sendmsg()
This commit removes the unix_schedule_gc() call from the af_unix sendmsg()
path to prevent priority inversion scenarios. The change relies on the
assumption that checking RLIMIT_NOFILE and running the garbage collector
asynchronously are sufficient to prevent historical soft lockup and
out-of-memory issues.
> diff --git a/net/unix/garbage.c b/net/unix/garbage.c
> index 0783555e25266..f180c59b3da9d 100644
> --- a/net/unix/garbage.c
> +++ b/net/unix/garbage.c
> @@ -300,8 +300,6 @@ int unix_prepare_fpl(struct scm_fp_list *fpl)
> if (!fpl->edges)
> goto err;
>
> - unix_schedule_gc(fpl->user);
> -
[Severity: High]
Does removing this call prevent the af_unix garbage collector from being
proactively triggered for isolated cyclic references?
If a long-running task generates cyclic af_unix references and drops its
file descriptors, the cyclic references' f_count remains > 0, so
unix_release_sock() is never called. Without this trigger, wouldn't the
garbage collector remain unscheduled unless the task exits or closes an
unrelated, non-cyclic af_unix socket?
Could this regression lead to legitimate operations failing with
-ETOOMANYREFS for unprivileged processes, or allow a privileged process
to bypass RLIMIT_NOFILE and leak memory unboundedly?
[Severity: Low]
Does removing this call leave the user parameter in unix_schedule_gc()
as dead code?
If all other callers now unconditionally pass NULL, the conditional logic
checking user in unix_schedule_gc() will permanently evaluate to false:
net/unix/garbage.c:unix_schedule_gc() {
...
if (user &&
READ_ONCE(user->unix_inflight) < UNIX_INFLIGHT_SANE_USER)
return;
...
if (user && READ_ONCE(unix_graph_cyclic_sccs))
flush_work(&unix_gc_work);
...
}
Should the user parameter and these checks be removed as well?
> return 0;
>
> err:
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784712370.git.namcao@linutronix.de?part=2
next prev parent reply other threads:[~2026-07-23 9:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 9:31 [PATCH net-next v3 0/3] af_unix: Fix priority inversion issue Nam Cao
2026-07-22 9:31 ` [PATCH net-next v3 1/3] af_unix: Schedule the garbage collector at task exit Nam Cao
2026-07-23 9:31 ` sashiko-bot
2026-07-22 9:31 ` [PATCH net-next v3 2/3] af_unix: Do not wait for garbage collector in sendmsg() Nam Cao
2026-07-23 9:31 ` sashiko-bot [this message]
2026-07-22 9:31 ` [PATCH net-next v3 3/3] af_unix: Clean up unix_schedule_gc() Nam Cao
2026-07-23 9:31 ` sashiko-bot
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=20260723093154.004131F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=namcao@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox