diff options
| author | Jens Axboe <axboe@kernel.dk> | 2026-07-30 06:50:13 -0600 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-07-30 10:35:26 -0600 |
| commit | 73e7019097473fc9f83a334ef2c6ab3343709fef (patch) | |
| tree | 7f69d767714aaff8452df6db15269b5264e6358a /io_uring | |
| parent | c905736a46892e4776efc7f50888d67715d6ec08 (diff) | |
| download | linux-73e7019097473fc9f83a334ef2c6ab3343709fef.tar.gz linux-73e7019097473fc9f83a334ef2c6ab3343709fef.zip | |
io_uring/futex: don't mark futex wake requests as inflight
Commit 079afb081c42 ("io_uring/futex: mark wait requests as inflight")
added inflight tracking to ensure that do_exit() ->
io_uring_files_cancel() finds and cancels pending futex waits before the
mm goes away, as a private futex wait depends on the mm private futex
hash staying alive for the duration of the request. However, as
io_futex_prep() is shared between FUTEX_WAIT and FUTEX_WAKE, wake
requests got marked as inflight as well.
A futex wake executes fully inline at issue time and never depends on
the mm staying alive after completion, hence there's no need to track
it. Kill it.
Cc: stable@vger.kernel.org
Fixes: 079afb081c42 ("io_uring/futex: mark wait requests as inflight")
Reported-by: Chengfeng Lin <lin2530632123@gmail.com>
Link: https://lore.kernel.org/io-uring/CANGjgdn=R_qyUdE=j9za+vkmqcxacbP-84OHXF4nZ4ho9qRyVg@mail.gmail.com/
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
| -rw-r--r-- | io_uring/futex.c | 11 | ||||
| -rw-r--r-- | io_uring/futex.h | 1 | ||||
| -rw-r--r-- | io_uring/opdef.c | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/io_uring/futex.c b/io_uring/futex.c index 906701b3c5c6..eea0425f2bcb 100644 --- a/io_uring/futex.c +++ b/io_uring/futex.c @@ -149,6 +149,17 @@ int io_futex_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) !futex_validate_input(iof->futex_flags, iof->futex_mask)) return -EINVAL; + return 0; +} + +int io_futex_wait_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) +{ + int ret; + + ret = io_futex_prep(req, sqe); + if (unlikely(ret)) + return ret; + /* Mark as inflight, so file exit cancelation will find it */ io_req_track_inflight(req); return 0; diff --git a/io_uring/futex.h b/io_uring/futex.h index d789fcf715e3..987db3f2c6d9 100644 --- a/io_uring/futex.h +++ b/io_uring/futex.h @@ -3,6 +3,7 @@ #include "cancel.h" int io_futex_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); +int io_futex_wait_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_futexv_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags); int io_futexv_wait(struct io_kiocb *req, unsigned int issue_flags); diff --git a/io_uring/opdef.c b/io_uring/opdef.c index 4e58eb1344ea..cf3aa2242cd7 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -467,7 +467,7 @@ const struct io_issue_def io_issue_defs[] = { }, [IORING_OP_FUTEX_WAIT] = { #if defined(CONFIG_FUTEX) - .prep = io_futex_prep, + .prep = io_futex_wait_prep, .issue = io_futex_wait, #else .prep = io_eopnotsupp_prep, |
