diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-10-27 16:08:31 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-11-02 22:45:30 +0100 |
commit | b54a14041ee6444692d95ff38c8b3d1af682aa17 (patch) | |
tree | 658c5839cb2eb6dd19429c5e4911ea9cd727d664 /io_uring/cancel.c | |
parent | io_uring/rsrc: unify file and buffer resource tables (diff) | |
download | linux-b54a14041ee6444692d95ff38c8b3d1af682aa17.tar.xz linux-b54a14041ee6444692d95ff38c8b3d1af682aa17.zip |
io_uring/rsrc: add io_rsrc_node_lookup() helper
There are lots of spots open-coding this functionality, add a generic
helper that does the node lookup in a speculation safe way.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/cancel.c')
-rw-r--r-- | io_uring/cancel.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/io_uring/cancel.c b/io_uring/cancel.c index 3a2996307025..bbca5cb69cb5 100644 --- a/io_uring/cancel.c +++ b/io_uring/cancel.c @@ -240,10 +240,12 @@ static int __io_sync_cancel(struct io_uring_task *tctx, /* fixed must be grabbed every time since we drop the uring_lock */ if ((cd->flags & IORING_ASYNC_CANCEL_FD) && (cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) { - if (unlikely(fd >= ctx->file_table.data.nr)) + struct io_rsrc_node *node; + + node = io_rsrc_node_lookup(&ctx->file_table.data, fd); + if (unlikely(!node)) return -EBADF; - fd = array_index_nospec(fd, ctx->file_table.data.nr); - cd->file = io_file_from_index(&ctx->file_table, fd); + cd->file = io_slot_file(node); if (!cd->file) return -EBADF; } |