* [BUG] io_uring/rsrc: failed file update still removes the old file
@ 2026-11-15 16:36 Cheng Yongkang
0 siblings, 0 replies; only message in thread
From: Cheng Yongkang @ 2026-11-15 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: io-uring, linux-kernel
Hi Jens,
This is a small error-path issue. It only happens when a fixed file
update fails, for example because userspace passes a closed fd, so it
may not matter much in practice.
__io_sqe_files_update() removes the old file from the slot before it
calls fget() on the new fd. If fget() fails, or the fd is an io_uring
fd, or the node allocation fails, the update stops there and reports
that entry as not done (an error, or a short count in a batch), but
the slot is already empty. The old file is gone, and if it was
registered with a tag, its tag CQE is posted as if it had been removed
on purpose. io_install_fixed_file() does it the other way round: it
checks the file and allocates the node before it resets the slot.
On v7.3, updating slot 0 with a closed fd returned -EBADF, posted the
old file's tag CQE, and a later fixed-file NOP on slot 0 got -EBADF.
Moving the removal after the new file and node are ready keeps the old
file on failure:
- if (io_reset_rsrc_node(ctx, &ctx->file_table.data, i))
- io_file_bitmap_clear(&ctx->file_table, i);
if (fd != -1) {
...
+ if (io_reset_rsrc_node(ctx, &ctx->file_table.data, i))
+ io_file_bitmap_clear(&ctx->file_table, i);
ctx->file_table.data.nodes[i] = node;
...
+ } else if (io_reset_rsrc_node(ctx, &ctx->file_table.data, i)) {
+ io_file_bitmap_clear(&ctx->file_table, i);
}
With this change the update still returns -EBADF, but slot 0 keeps
working and no tag CQE is posted. Replacement, removal with fd -1 and
SKIP behave as before, and in a partial update the entries before the
failing one are still applied. In next-20261113 the removal still
comes before fget(). I can send a patch if you want one.
Thanks,
Cheng Yongkang
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-15 16:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 16:36 [BUG] io_uring/rsrc: failed file update still removes the old file Cheng Yongkang
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®