From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385302; b=ljnhNQPzv1WzOD9FStx25WYjqU5JVNF6ynB9cQ66zwzP98Z11DoN6Tb5VUwiiJ6O6xHe v9IoifD+IpvlhbIz6tLi7VZn5im5yGacbuGMUonu38O8UB4nyKR8zuMmGQHFcKHMYGZy4 /biChF7wvF7kDgqCTjhsr8vnM4hjQdZeEMGxJWwC7d26iMMDMNwV/4rlSGoRKecvpZTqq dDsfBlkj3Pj+68l6wbOYbqzVx5prQoHTJwA9q9jEyFzZq93taKXTJAj+ue4SfC91BZfyG rsefX8bBAb2bDNNCZYicPtMwLRpPDADS55Opgythwv5V5KwzLK6Pw/3LijtGg+SKEsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385302; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=FwWhddoWP2k3AleEvlUiWdbTIoa40Z72pDu8xILakdI=; b=tBAlXGVqzEUqQOIYbLkMiZKXWQ1wmlqO1aWjiWG06fHExCASVUMjwiZ/V9CCuEHEkWVJ zis4BWD2+mfm16sV0xsRFYeCMnKq7Rl81Cd9VWdBJWDob8xsWvMAz7eEw/U0GZvGGN/Kh NcRpT9/vLCPEkjhYO/kNsSWI7Tm9wI+pv6Ur0AzElROSKK24In40W6gT5HLizP5RwG73e ystSGRT0A8ZYaUUwoCiuJVKBpJqeDzuNT2A/0Kru5VWrTiHhJm84op8z5FRYAoqvpIWOA 6hHyz2Ry4Zg7KJ60sWHvdIv0pJ/TC5j1dNBY1iWZ9k8+rpVSFVnm2UlqarRTjsDFgJQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=x9L4R83T; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 248A8606A322; Fri, 4 Dec 2026 11:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=x9L4R83T Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CB4C1F00935; Fri, 4 Dec 2026 11:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385301; bh=FwWhddoWP2k3AleEvlUiWdbTIoa40Z72pDu8xILakdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=x9L4R83TZ0a9GVNKpL2lbMohwLO4+rX4yhFawJOfIi5i7q60kYPH3yEbDXWgKQLwJ 1PsCYR7f8NKxYHVaA+g93t3QfF09hsAuu8Vn2ZPtW/o7raMrZYdAkCZECHP0To9GuM +96PbLAP7AOtU/XmjkGCUfC6dR86br2cRD0darn4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mani Tofigh , "Christian Brauner (Amutable)" Subject: [PATCH 6.6 0497/1167] eventpoll: wake the next waiter when a woken waiter is killed Date: Fri, 4 Dec 2026 18:58:44 +0900 Message-ID: <20261204100715.011249433@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mani Tofigh commit 9f4413e522faed76f4cf610098b2369eb3ba1f1c upstream. Processes sharing an epoll instance can sleep forever while an event is ready. An event wakes only one waiter, which then wakes the next one in ep_done_scan() if events are still ready. Since commit c257a340ede0 ("fs, epoll: short circuit fetching events if thread has been killed"), ep_send_events() returns before the scan when the waiter has a fatal signal. If the woken waiter is killed before it runs, nobody wakes the next one: Task A Task B Task C epoll_wait(ep, -1) epoll_wait(ep, -1) write(efd) /* wakes A only */ kill(A, SIGKILL) ep_send_events() return -EINTR /* skips ep_done_scan() */ /* still asleep */ B then sleeps until another file on the instance becomes ready, if ever. This can hit eg a pre-fork server whose worker gets OOM killed. Commit 7fab29e35630 ("fs/epoll: restore waking from ep_done_scan()") fixed the same kind of hang when the wakeup in ep_done_scan() was removed. Keep the early return so that a dying task still doesn't take events nobody will see, but wake the next waiter there if events are ready, as ep_done_scan() would have. With the fix, B gets the event. This bug was identified and confirmed with the help of a deterministic hypervisor currently under development. The C reproducer below however hits it within about 2s. Fixes: c257a340ede0 ("fs, epoll: short circuit fetching events if thread has been killed") Cc: stable@vger.kernel.org Signed-off-by: Mani Tofigh Link: https://patch.msgid.link/20261103-epoll-killed-waiter-v1-1-36e08c16b8a2@columbia.edu Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Greg Kroah-Hartman --- fs/eventpoll.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1665,10 +1665,17 @@ static int ep_send_events(struct eventpo /* * Always short-circuit for fatal signals to allow threads to make a * timely exit without the chance of finding more events available and - * fetching repeatedly. + * fetching repeatedly. The wakeup that got us here may have been the + * only one for the events on ->rdllist, so pass it on to the next + * waiter, as ep_done_scan() would have. */ - if (fatal_signal_pending(current)) + if (fatal_signal_pending(current)) { + spin_lock_irq(&ep->lock); + if (!list_empty(&ep->rdllist)) + wake_up(&ep->wq); + spin_unlock_irq(&ep->lock); return -EINTR; + } init_poll_funcptr(&pt, NULL);