public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: harshal24-chavan <harshal24.chavan@gmail.com>
To: krisman@kernel.org
Cc: axboe@kernel.dk, gustavoars@kernel.org,
	harshal24.chavan@gmail.com, io-uring@vger.kernel.org,
	kees@kernel.org, linux-hardening@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] io_uring/register: add IORING_REGISTER_CLONE_FILES opcode
Date: Fri, 19 Jun 2026 13:10:11 +0530	[thread overview]
Message-ID: <20260619074011.15289-1-harshal24.chavan@gmail.com> (raw)
In-Reply-To: <87a4ssyey0.fsf@mailhost.krisman.be>

On 6/17/26 18:33, Gabriel Krisman Bertazi wrote:
> IIUC, the IORING_REGISTER_DST_REPLACE exists for backward compatibility,
> since originally the buffer cloning would fail if existing elements were
> already there.  It is kind of superflous in a new operation but I suppose
> it is here to mirror the semantics of io_clone_buffers, which is ok, but
> then...
>
> This free should at least be gated on ctx->file_table->data.nr.  We are
> always replacing the ->file_table if it was initialized, so it is a bit
> more logical to check the table directly.

Agreed. In v3, I have gated the io_free_file_tables() call directly on 
ctx->file_table.data.nr as suggested.

> > +	/* not allowed unless REPLACE is set */
> > +	if (!(clone_arg.flags & IORING_REGISTER_DST_REPLACE) &&
> > +	    ctx->file_table.data.nr)
> > +		return -EBUSY;
> This check is duplicated in io_clone_files.

I have removed this duplicate check from the parent function in v3.

> > +	src_ctx = file->private_data;
> > +	if (src_ctx != ctx) {
> Shouldn't we just fail if ctx == src_ctx ?

Yes, I have updated this to explicitly fail with -EINVAL 
if ctx == src_ctx to prevent self-cloning in v3. Thanks for catching this.

> > +		/* Prevent cross-process hijacking */
> > +		if (src_ctx->submitter_task &&
> > +		    src_ctx->submitter_task != current) {
> > +			ret = -EEXIST;
> > +			goto out;
> Is limiting the feature to the submitter_task necessary to safely copy
> the table even if the lock is held?  The use-case for this feature would
> be setting up a single ring with its file table and then replicating it
> on other threads, on the common model of one-ring per thread. This check
> limits it.

I have entirely removed the submitter_task check in v3.

      reply	other threads:[~2026-06-19  7:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17  8:16 [PATCH v2] [PATCH v2] io_uring/register: add IORING_REGISTER_CLONE_FILES opcode harshal24-chavan
2026-06-17 14:54 ` Jens Axboe
2026-06-19  7:32   ` Harshal Chavan
2026-06-17 22:33 ` Gabriel Krisman Bertazi
2026-06-19  7:40   ` harshal24-chavan [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=20260619074011.15289-1-harshal24.chavan@gmail.com \
    --to=harshal24.chavan@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=gustavoars@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=kees@kernel.org \
    --cc=krisman@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@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