public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: io-uring@vger.kernel.org, brauner@kernel.org,
	Jann Horn <jannh@google.com>, Kees Cook <kees@kernel.org>
Subject: Re: [PATCH 6/6] io_uring: allow registration of per-task restrictions
Date: Mon, 19 Jan 2026 13:29:44 -0700	[thread overview]
Message-ID: <4d69cb42-5eff-4233-bfb1-1fbd63d85356@kernel.dk> (raw)
In-Reply-To: <2026-01-19-undead-spiral-scalpel-grandson-R0Uhz9@cyphar.com>

>> +static int io_register_restrictions_task(void __user *arg, unsigned int nr_args)
>> +{
>> +	struct io_uring_task_restriction __user *ures = arg;
>> +	struct io_uring_task_restriction tres;
>> +	struct io_restriction *res;
>> +	int ret;
> 
> You almost certainly want to copy the seccomp logic of disallowing the
> setting of restrictions unless no_new_privs is set or the process has
> CAP_SYS_ADMIN.

(this is why I missed it, it's 288 lines down of quoted email?)

Good point, yes can do.

> While seccomp is more dangerous in this respect (as it allows you to
> modify the return value of a syscall), being able to alter the execution
> of setuid binaries usually leads to security issues, so it's probably
> best to just copy what seccomp does here.

Agree, that was kind of my goal, just largely mimic that part to avoid
surprises.

>> +	/* Disallow if task already has registered restrictions */
>> +	if (current->io_uring_restrict)
>> +		return -EPERM;
> 
> I guess specifying "stacked" restrictions (a-la seccomp) is intended as
> future work?

You can stack already, you just stack within the current set.

> This is kind of critical for both nesting use-cases and for making this
> usable more widely (I imagine systemd will want to set system-wide
> restrictions which would lock out programs from being able to set their
> own process-wide restrictions -- nested containers are also a fairly
> common use-case these days too).
> 
> (For containers we would probably only really use the cBPF stuff but it
> would be nice for them to both be stackable -- if only for the reason
> that you could set them in any order.)

Agree and this is why you can already do that.

>> +	if (nr_args != 1)
>> +		return -EINVAL;
>> +
>> +	if (copy_from_user(&tres, arg, sizeof(tres)))
>> +		return -EFAULT;
>> +
>> +	if (tres.flags)
>> +		return -EINVAL;
>> +	if (!mem_is_zero(tres.resv, sizeof(tres.resv)))
>> +		return -EINVAL;
> 
> I would suggest using copy_struct_from_user() to make extensions easier,
> but I don't know if that is the kind of thing you feel necessary for
> io_uring APIs.

I don't disagree with that, but the io_uring uapi in this regard has
been extensible in the past with just reserved fields. Hence I'd rather
just stick with that approach, rather than make this case "special".

>> +static int io_register_bpf_filter_task(void __user *arg, unsigned int nr_args)
>> +{
>> +	struct io_restriction *res;
>> +	int ret;
>> +
>> +	if (nr_args != 1)
>> +		return -EINVAL;
> 
> Same comment as above about no_new_privs / CAP_SYS_ADMIN.

Agree, will make that change.

-- 
Jens Axboe

      parent reply	other threads:[~2026-01-19 20:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18 17:16 [PATCHSET v5] Inherited restrictions and BPF filtering Jens Axboe
2026-01-18 17:16 ` [PATCH 1/6] io_uring: add support for BPF filtering for opcode restrictions Jens Axboe
2026-01-19 18:51   ` Aleksa Sarai
2026-01-19 20:17     ` Jens Axboe
2026-01-18 17:16 ` [PATCH 2/6] io_uring/net: allow filtering on IORING_OP_SOCKET data Jens Axboe
2026-01-18 17:16 ` [PATCH 3/6] io_uring/bpf_filter: cache lookup table in ctx->bpf_filters Jens Axboe
2026-01-18 17:16 ` [PATCH 4/6] io_uring/bpf_filter: add ref counts to struct io_bpf_filter Jens Axboe
2026-01-18 17:16 ` [PATCH 5/6] io_uring: add task fork hook Jens Axboe
2026-01-18 17:16 ` [PATCH 6/6] io_uring: allow registration of per-task restrictions Jens Axboe
2026-01-19 17:54   ` Aleksa Sarai
2026-01-19 18:02     ` Jens Axboe
2026-01-19 20:29     ` Jens Axboe [this message]

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=4d69cb42-5eff-4233-bfb1-1fbd63d85356@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=cyphar@cyphar.com \
    --cc=io-uring@vger.kernel.org \
    --cc=jannh@google.com \
    --cc=kees@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