From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 1/5] io_uring/register: have io_parse_restrictions() return number of ops
Date: Mon, 12 Jan 2026 08:14:41 -0700 [thread overview]
Message-ID: <20260112151905.200261-2-axboe@kernel.dk> (raw)
In-Reply-To: <20260112151905.200261-1-axboe@kernel.dk>
Rather than return 0 on success, return >= 0 for success, where the
return value is that number of parsed entries. As before, any < 0
return is an error.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
io_uring/register.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/io_uring/register.c b/io_uring/register.c
index 62d39b3ff317..2611cf87ecf8 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -103,6 +103,10 @@ static int io_register_personality(struct io_ring_ctx *ctx)
return id;
}
+/*
+ * Returns number of restrictions parsed and added on success, or < 0 for
+ * an error.
+ */
static __cold int io_parse_restrictions(void __user *arg, unsigned int nr_args,
struct io_restriction *restrictions)
{
@@ -145,9 +149,7 @@ static __cold int io_parse_restrictions(void __user *arg, unsigned int nr_args,
goto err;
}
}
-
- ret = 0;
-
+ ret = nr_args;
err:
kfree(res);
return ret;
@@ -168,11 +170,12 @@ static __cold int io_register_restrictions(struct io_ring_ctx *ctx,
ret = io_parse_restrictions(arg, nr_args, &ctx->restrictions);
/* Reset all restrictions if an error happened */
- if (ret != 0)
+ if (ret < 0) {
memset(&ctx->restrictions, 0, sizeof(ctx->restrictions));
- else
- ctx->restrictions.registered = true;
- return ret;
+ return ret;
+ }
+ ctx->restrictions.registered = true;
+ return 0;
}
static int io_register_enable_rings(struct io_ring_ctx *ctx)
--
2.51.0
next prev parent reply other threads:[~2026-01-12 15:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 15:14 [PATCHSET 0/5] io_uring restrictions cleanups and improvements Jens Axboe
2026-01-12 15:14 ` Jens Axboe [this message]
2026-01-12 15:14 ` [PATCH 2/5] io_uring/register: have io_parse_restrictions() set restrictions enabled Jens Axboe
2026-01-12 15:14 ` [PATCH 3/5] io_uring/register: set ctx->restricted when restrictions are parsed Jens Axboe
2026-01-12 15:14 ` [PATCH 4/5] io_uring: move ctx->restricted check into io_check_restriction() Jens Axboe
2026-01-12 15:14 ` [PATCH 5/5] io_uring: track restrictions separately for IORING_OP and IORING_REGISTER Jens Axboe
2026-01-13 17:27 ` [PATCHSET 0/5] io_uring restrictions cleanups and improvements Gabriel Krisman Bertazi
2026-01-13 18:22 ` Jens Axboe
2026-01-13 18:23 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260112151905.200261-2-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox