io_uring: don't allow duplicate registrations
Subsystems (2)
PATCH 1/1 io_uring: don't allow duplicate registrations
Hi, Jens,
It looks to me like calling io_uring_register more than once (for either IORING_REGISTER_BUFFERS or IORING_REGISTER_FILES) will leak the references taken in previous calls.
---
If this makes sense to you, feel free to just fold this into your patches w/o any attribution.
fs/io_uring.c +6 -0
@@ -1399,6 +1399,9 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,if (!nr_args)return -EINVAL ; +if (ctx->user_files) +return -EINVAL ; + ctx->user_files =kcalloc (nr_args,sizeof (struct file *),GFP_KERNEL );if (!ctx->user_files)return -ENOMEM ;
@@ -1580,6 +1583,9 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,if (!nr_args || nr_args >UIO_MAXIOV )return -EINVAL ; +if (ctx->user_bufs) +return -EINVAL ; + ctx->user_bufs =kcalloc (nr_args,sizeof (struct io_mapped_ubuf ),GFP_KERNEL );if (!ctx->user_bufs)
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>
Jens Axboe
maintainerQuoted 5 lines · Jeff Moyer
Hi, Jens,
It looks to me like calling
io_uring_registermore than once (for eitherIORING_REGISTER_BUFFERSorIORING_REGISTER_FILES) will leak the references taken in previous calls.
Oops, thanks for that. Let's make it -EBUSY though, everything ends up being -EINVAL and that sometimes makes it hard for an application to figure out wtf is going on.
I also added -EINVAL for unregister when not already setup.
Signature · 7 lines
Jens Axboe -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"[email protected]">[email protected]</a>
Quoted 10 lines · Jens Axboe
Quoted 5 lines · Jeff Moyer
Hi, Jens,
It looks to me like calling
io_uring_registermore than once (for eitherIORING_REGISTER_BUFFERSorIORING_REGISTER_FILES) will leak the references taken in previous calls.Oops, thanks for that. Let's make it
-EBUSYthough, everything ends up being-EINVALand that sometimes makes it hard for an application to figure out wtf is going on.
Sounds good.
Quoted 1 line
I also added
-EINVALfor unregister when not already setup.
Yep, I saw that.
-Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>
Jens Axboe
maintainerQuoted 13 lines · Jeff Moyer
Quoted 10 lines · Jens Axboe
Quoted 5 lines · Jeff Moyer
Hi, Jens,
It looks to me like calling
io_uring_registermore than once (for eitherIORING_REGISTER_BUFFERSorIORING_REGISTER_FILES) will leak the references taken in previous calls.Oops, thanks for that. Let's make it
-EBUSYthough, everything ends up being-EINVALand that sometimes makes it hard for an application to figure out wtf is going on.
Quoted 5 lines
Sounds good.
Quoted 1 line
I also added
-EINVALfor unregister when not already setup.Yep, I saw that.
Changed it to -ENXIO, that's more descriptive.
Signature · 7 lines
Jens Axboe -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"[email protected]">[email protected]</a>