Skip to contentSkip to conversation

io_uring: return EBADFD when ring isn't in the right state

PATCH In review Stefano Garzarella 2 participants 3 messages Sep 8, 2020 – Sep 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: return EBADFD when ring isn't in the right state

This patch uniforms the returned error (EBADFD) when the ring state (enabled/disabled) is not the expected one.

The changes affect io_uring_enter() and io_uring_register() syscalls.

---

Hi Jens,
I also updated the test/register-restrictions in liburing here:

https://github.com/stefano-garzarella/liburing (branch: fix-disabled-ring-error)

Thanks,
Stefano

---
 fs/io_uring.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/io_uring.c +3 -2
index 0490edfcdd88..cf5992e79d88 100644
@@ -8642,6 +8642,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
 	if (!percpu_ref_tryget(&ctx->refs))
 		goto out_fput;
 
+	ret = -EBADFD;
 	if (ctx->flags & IORING_SETUP_R_DISABLED)
 		goto out_fput;
 
@@ -9137,7 +9138,7 @@ static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg,
 
 	/* Restrictions allowed only if rings started disabled */
 	if (!(ctx->flags & IORING_SETUP_R_DISABLED))
-		return -EINVAL;
+		return -EBADFD;
 
 	/* We allow only a single restrictions registration */
 	if (ctx->restrictions.registered)
@@ -9201,7 +9202,7 @@ static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg,
 static int io_register_enable_rings(struct io_ring_ctx *ctx)
 {
 	if (!(ctx->flags & IORING_SETUP_R_DISABLED))
-		return -EINVAL;
+		return -EBADFD;
 
 	if (ctx->restrictions.registered)
 		ctx->restricted = 1;
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 4 lines · Stefano Garzarella

This patch uniforms the returned error (EBADFD) when the ring state (enabled/disabled) is not the expected one.

The changes affect io_uring_enter() and io_uring_register() syscalls.

I added a Fixes line:

Fixes 7ec3d1dd9378 ("io_uring: allow disabling rings during the creation")

and applied it, thanks!

Quoted 1 line

https://github.com/stefano-garzarella/liburing (branch: fix-disabled-ring-error)

I'll check and pull that one too.

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 9 lines · Jens Axboe
Quoted 4 lines · Stefano Garzarella

This patch uniforms the returned error (EBADFD) when the ring state (enabled/disabled) is not the expected one.

The changes affect io_uring_enter() and io_uring_register() syscalls.

I added a Fixes line:

Fixes 7ec3d1dd9378 ("io_uring: allow disabling rings during the creation")

Oh right, I forgot!

Quoted 7 lines

and applied it, thanks!

Quoted 1 line

https://github.com/stefano-garzarella/liburing (branch: fix-disabled-ring-error)

I'll check and pull that one too.

Thanks,
Stefano