7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Juanlu Herrero commit 937d38dcacd675dc0572d6c9b6743960df3128ed upstream. If a wakeup sets IO_POLL_RETRY_FLAG between the owning task consuming the existing instance of IO_POLL_RETRY_FLAG and the loop check of io_poll_check_events(), then we stall on processing the request until an unrelated wakeup comes along. Using atomic_cmpxchg instead of atomic_sub_return to guarantee both the count v and poll_refs are 0 and no wake-ups are missed. Cc: stable@vger.kernel.org Fixes: a26a35e9019f ("io_uring: make poll refs more robust") Signed-off-by: Juanlu Herrero Assisted-by: LLM Suggested-by: Anand Natarajan Link: https://patch.msgid.link/20261013-pu-cmpxchg-v1-1-4ddc10fd8a03@fastmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/poll.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/io_uring/poll.c +++ b/io_uring/poll.c @@ -330,7 +330,8 @@ static int io_poll_check_events(struct i * Release all references, retry if someone tried to restart * task_work while we were executing it. */ - } while (atomic_sub_return(v, &req->poll_refs) & IO_POLL_REF_MASK); + v &= IO_POLL_REF_MASK; + } while (atomic_cmpxchg(&req->poll_refs, v, 0) != v); io_napi_add(req); return IOU_POLL_NO_ACTION;