From: Kuniyuki Iwashima <kuniyu@google.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org, Lim Chanyoun <onleaf322@gmail.com>
Subject: [PATCH v1 net] af_unix: Convert unsigned long to u64 for GC.
Date: Wed, 4 Nov 2026 08:20:55 +0000 [thread overview]
Message-ID: <20261104082058.452188-1-kuniyu@google.com> (raw)
Lim Chanyoun reported that unix_vertex_max_scc_index could
wrap around on 32-bit kernels, which confuses GC into purging
a live socket receive queue.
I apparently designed GC with u64 in mind to avoid wraparound. [0]
Let's make it true on 32-bit kernels.
Note that unix_vertex.{out_degree,index} are converted for
consistency; they are bounded by the number of allocated
objects and do not exceed UINT_MAX on 32-bit kernels.
Fixes: 4090fa373f0e ("af_unix: Replace garbage collection algorithm.")
Link: https://lore.kernel.org/netdev/20240228030508.31297-1-kuniyu@amazon.com/ #[0]
Reported-by: Lim Chanyoun <onleaf322@gmail.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
net/unix/garbage.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index da774f56ca64..a0b515354e8b 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -78,9 +78,9 @@ struct unix_vertex {
struct list_head edges;
struct list_head entry;
struct list_head scc_entry;
- unsigned long out_degree;
- unsigned long index;
- unsigned long scc_index;
+ u64 out_degree;
+ u64 index;
+ u64 scc_index;
};
struct unix_edge {
@@ -148,8 +148,8 @@ enum unix_vertex_index {
UNIX_VERTEX_INDEX_START,
};
-static unsigned long unix_vertex_unvisited_index = UNIX_VERTEX_INDEX_MARK1;
-static unsigned long unix_vertex_max_scc_index = UNIX_VERTEX_INDEX_START;
+static u64 unix_vertex_unvisited_index = UNIX_VERTEX_INDEX_MARK1;
+static u64 unix_vertex_max_scc_index = UNIX_VERTEX_INDEX_START;
static void unix_add_edge(struct scm_fp_list *fpl, struct unix_edge *edge)
{
@@ -372,7 +372,7 @@ static bool unix_vertex_dead(struct unix_vertex *vertex)
}
static LIST_HEAD(unix_visited_vertices);
-static unsigned long unix_vertex_grouped_index = UNIX_VERTEX_INDEX_MARK2;
+static u64 unix_vertex_grouped_index = UNIX_VERTEX_INDEX_MARK2;
static bool unix_scc_dead(struct list_head *scc)
{
@@ -450,14 +450,14 @@ static bool unix_scc_cyclic(struct list_head *scc)
return false;
}
-static unsigned long __unix_walk_scc(struct unix_vertex *vertex,
- unsigned long *last_index,
- struct sk_buff_head *hitlist)
+static u64 __unix_walk_scc(struct unix_vertex *vertex,
+ u64 *last_index,
+ struct sk_buff_head *hitlist)
{
- unsigned long cyclic_sccs = 0;
LIST_HEAD(vertex_stack);
struct unix_edge *edge;
LIST_HEAD(edge_stack);
+ u64 cyclic_sccs = 0;
next_vertex:
/* Push vertex to vertex_stack and mark it as on-stack
@@ -553,12 +553,12 @@ static unsigned long __unix_walk_scc(struct unix_vertex *vertex,
return cyclic_sccs;
}
-static unsigned long unix_graph_cyclic_sccs;
+static u64 unix_graph_cyclic_sccs;
static void unix_walk_scc(struct sk_buff_head *hitlist)
{
- unsigned long last_index = UNIX_VERTEX_INDEX_START;
- unsigned long cyclic_sccs = 0;
+ u64 last_index = UNIX_VERTEX_INDEX_START;
+ u64 cyclic_sccs = 0;
unix_vertex_max_scc_index = UNIX_VERTEX_INDEX_START;
@@ -582,7 +582,7 @@ static void unix_walk_scc(struct sk_buff_head *hitlist)
static void unix_walk_scc_fast(struct sk_buff_head *hitlist)
{
- unsigned long cyclic_sccs = unix_graph_cyclic_sccs;
+ u64 cyclic_sccs = unix_graph_cyclic_sccs;
while (!list_empty(&unix_unvisited_vertices)) {
struct unix_vertex *vertex;
--
2.56.0.385.gac671c819a-goog
next reply other threads:[~2026-11-04 8:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 8:20 Kuniyuki Iwashima [this message]
2026-11-04 8:23 ` [PATCH v1 net] af_unix: Convert unsigned long to u64 for GC netdev-bot+sinfo
2026-11-04 8:24 ` Kuniyuki Iwashima
2026-11-10 2:54 ` patchwork-bot+netdevbpf
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=20261104082058.452188-1-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=onleaf322@gmail.com \
--cc=pabeni@redhat.com \
/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