Skip to content

Commit 0cfa78c

Browse files
q2vengregkh
authored andcommitted
af_unix: Set gc_in_progress to true in unix_gc().
[ Upstream commit d82ba05 ] 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: 8b90a9f ("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>
1 parent 3c49985 commit 0cfa78c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

net/unix/garbage.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ static void __unix_gc(struct work_struct *work)
606606
struct sk_buff_head hitlist;
607607
struct sk_buff *skb;
608608

609+
WRITE_ONCE(gc_in_progress, true);
610+
609611
spin_lock(&unix_gc_lock);
610612

611613
if (unix_graph_state == UNIX_GRAPH_NOT_CYCLIC) {

0 commit comments

Comments
 (0)