public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH for-next] io_uring: return EBADFD when ring isn't in the right state
@ 2020-09-08 16:52 Stefano Garzarella
  2020-09-08 17:02 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Stefano Garzarella @ 2020-09-08 16:52 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Alexander Viro, linux-fsdevel, linux-kernel

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.

Signed-off-by: Stefano Garzarella <[email protected]>
---

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(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 0490edfcdd88..cf5992e79d88 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] io_uring: return EBADFD when ring isn't in the right state
  2020-09-08 16:52 [PATCH for-next] io_uring: return EBADFD when ring isn't in the right state Stefano Garzarella
@ 2020-09-08 17:02 ` Jens Axboe
  2020-09-09  7:09   ` Stefano Garzarella
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2020-09-08 17:02 UTC (permalink / raw)
  To: Stefano Garzarella; +Cc: io-uring, Alexander Viro, linux-fsdevel, linux-kernel

On 9/8/20 10:52 AM, Stefano Garzarella wrote:
> 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!

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

I'll check and pull that one too.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] io_uring: return EBADFD when ring isn't in the right state
  2020-09-08 17:02 ` Jens Axboe
@ 2020-09-09  7:09   ` Stefano Garzarella
  0 siblings, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2020-09-09  7:09 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Alexander Viro, linux-fsdevel, linux-kernel

On Tue, Sep 08, 2020 at 11:02:48AM -0600, Jens Axboe wrote:
> On 9/8/20 10:52 AM, Stefano Garzarella wrote:
> > 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!

> 
> and applied it, thanks!
> 
> > https://github.com/stefano-garzarella/liburing (branch: fix-disabled-ring-error)
> 
> I'll check and pull that one too.
> 

Thanks,
Stefano


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-09  7:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-08 16:52 [PATCH for-next] io_uring: return EBADFD when ring isn't in the right state Stefano Garzarella
2020-09-08 17:02 ` Jens Axboe
2020-09-09  7:09   ` Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox