From: Joe Damato <jdamato@fastly.com>
To: linux-fsdevel@vger.kernel.org
Cc: Joe Damato <jdamato@fastly.com>,
Christian Brauner <brauner@kernel.org>,
Mike Pagano <mpagano@gentoo.org>,
Carlos Llamas <cmllamas@google.com>,
Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH vfs.fixes] eventpoll: Prevent hang in epoll_wait
Date: Tue, 29 Apr 2025 15:34:19 +0000 [thread overview]
Message-ID: <20250429153419.94723-1-jdamato@fastly.com> (raw)
In commit 0a65bc27bd64 ("eventpoll: Set epoll timeout if it's in the
future"), a bug was introduced causing the loop in ep_poll to hang under
certain circumstances.
When the timeout is non-NULL and ep_schedule_timeout returns false, the
flag timed_out was not set to true. This causes a hang.
Adjust the logic and set timed_out, if needed, fixing the original code.
Reported-by: Christian Brauner <brauner@kernel.org>
Closes: https://lore.kernel.org/linux-fsdevel/20250426-haben-redeverbot-0b58878ac722@brauner/
Reported-by: Mike Pagano <mpagano@gentoo.org>
Closes: https://bugs.gentoo.org/954806
Reported-by: Carlos Llamas <cmllamas@google.com>
Closes: https://lore.kernel.org/linux-fsdevel/aBAB_4gQ6O_haAjp@google.com/
Fixes: 0a65bc27bd64 ("eventpoll: Set epoll timeout if it's in the future")
Tested-by: Carlos Llamas <cmllamas@google.com>
Signed-off-by: Joe Damato <jdamato@fastly.com>
---
fs/eventpoll.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 4bc264b854c4..1a5d1147f082 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -2111,7 +2111,9 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
write_unlock_irq(&ep->lock);
- if (!eavail && ep_schedule_timeout(to))
+ if (!ep_schedule_timeout(to))
+ timed_out = 1;
+ else if (!eavail)
timed_out = !schedule_hrtimeout_range(to, slack,
HRTIMER_MODE_ABS);
__set_current_state(TASK_RUNNING);
base-commit: f520bed25d17bb31c2d2d72b0a785b593a4e3179
--
2.43.0
next reply other threads:[~2025-04-29 15:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 15:34 Joe Damato [this message]
2025-04-29 18:19 ` Jan Kara
2025-04-29 19:28 ` Max Kellermann
2025-04-29 20:04 ` Joe Damato
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=20250429153419.94723-1-jdamato@fastly.com \
--to=jdamato@fastly.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpagano@gentoo.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®