* [PATCH 1/1] io_uring: protect mem region deregistration
@ 2025-10-15 12:07 Pavel Begunkov
2025-10-15 14:02 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2025-10-15 12:07 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence
io_create_region_mmap_safe() protects publishing of a region against
concurrent mmap calls, however we should also protect against it when
removing a region. There is a gap io_register_mem_region() where it
safely publishes a region, but then copy_to_user goes wrong and it
unsafely frees the region.
Cc: stable@vger.kernel.org
Fixes: 087f997870a94 ("io_uring/memmap: implement mmap for regions")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/register.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/io_uring/register.c b/io_uring/register.c
index 43f04c47522c..58d43d624856 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -613,6 +613,7 @@ static int io_register_mem_region(struct io_ring_ctx *ctx, void __user *uarg)
if (ret)
return ret;
if (copy_to_user(rd_uptr, &rd, sizeof(rd))) {
+ guard(mutex)(&ctx->mmap_lock);
io_free_region(ctx, &ctx->param_region);
return -EFAULT;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] io_uring: protect mem region deregistration
2025-10-15 12:07 [PATCH 1/1] io_uring: protect mem region deregistration Pavel Begunkov
@ 2025-10-15 14:02 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-10-15 14:02 UTC (permalink / raw)
To: io-uring, Pavel Begunkov
On Wed, 15 Oct 2025 13:07:23 +0100, Pavel Begunkov wrote:
> io_create_region_mmap_safe() protects publishing of a region against
> concurrent mmap calls, however we should also protect against it when
> removing a region. There is a gap io_register_mem_region() where it
> safely publishes a region, but then copy_to_user goes wrong and it
> unsafely frees the region.
>
>
> [...]
Applied, thanks!
[1/1] io_uring: protect mem region deregistration
commit: be7cab44ed099566c605a8dac686c3254db01b35
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-15 14:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 12:07 [PATCH 1/1] io_uring: protect mem region deregistration Pavel Begunkov
2025-10-15 14:02 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox