summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@google.com>2026-07-01 09:53:06 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-04 13:44:16 +0200
commit0cfa78c050662784fc8e3ab26dbfd1dc632b2082 (patch)
tree69213ab5d8b01270ed0cc4e1df8a662172feb8f1
parent3c499851753a24d2e148d4e9ca51764c0c51554e (diff)
downloadlinux-stable-0cfa78c050662784fc8e3ab26dbfd1dc632b2082.tar.gz
linux-stable-0cfa78c050662784fc8e3ab26dbfd1dc632b2082.zip
af_unix: Set gc_in_progress to true in unix_gc().
[ Upstream commit d82ba05263c69fa2437fe93e4e561cc40f4c03af ] Igor Ushakov reported that unix_gc() could run with gc_in_progress being false if the work is scheduled while running: Thread 1 Thread 2 Thread 3 -------- -------- -------- unix_schedule_gc() unix_schedule_gc() `- if (!gc_in_progress) `- if (!gc_in_progress) |- gc_in_progress = true | `- queue_work() | unix_gc() <----------------/ | | |- gc_in_progress = true ... `- queue_work() | | `- gc_in_progress = false | | unix_gc() <---------------------------------------------' | ... /* gc_in_progress == false */ | `- gc_in_progress = false unix_peek_fpl() relies on gc_in_progress not to confuse GC by MSG_PEEK. Let's set gc_in_progress to true in unix_gc(). Fixes: 8b90a9f819dc ("af_unix: Run GC on only one CPU.") Reported-by: Igor Ushakov <sysroot314@gmail.com> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260501073945.1884564-1-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> [ Add setting gc_in_progress in __unix_gc(). Keep the existing set in unix_gc() for wait_for_unix_gc() over-limit throttling. ] Signed-off-by: Igor Ushakov <sysroot314@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/unix/garbage.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 529b21d043d9..398671709026 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -606,6 +606,8 @@ static void __unix_gc(struct work_struct *work)
struct sk_buff_head hitlist;
struct sk_buff *skb;
+ WRITE_ONCE(gc_in_progress, true);
+
spin_lock(&unix_gc_lock);
if (unix_graph_state == UNIX_GRAPH_NOT_CYCLIC) {