Re: [PATCH v4] io_uring/register: add IORING_REGISTER_CLONE_FILES opcode

From: Harshal Chavan

Date: Tue Jun 23 2026 - 12:53:21 EST


Gabriel Krisman Bertazi @ 2026-06-22 20:04 UTC writes:

>Hello,
>
>Do you have the liburing side and test cases?
>
>A few comments inline.

Hello,
Yes I will update the liburing side with helper function
and add appropriate test cases.

>> + /* clone file descriptors from another ring*/
> ^ spacing

Fixed in v5

>> + if (ctx->user != src_ctx->user || ctx->mm_account != src_ctx->mm_account)
>> + return -EINVAL;
>
>I don't think it makes sense to check ->user here. But is mm_account
>necessary either? How could you get the src_ctx from another process?

Yes, Keeping this check would unnecessarily break valid use case like
Root user passing FDs to guest user

Removed it completely in v5, thanks for catching this!.


>> + registered_src = (clone_arg.flags & IORING_REGISTER_SRC_REGISTERED) != 0;
>
>This is better written as
>
>registered_src = !!(clone_arg.flags & IORING_REGISTER_SRC_REGISTERED);

Understood, updated this in v5

>> +out:
>> + if (src_ctx != ctx)
>> + mutex_unlock(&src_ctx->uring_lock);
>
>Make the mutex_unlock unconditionally above the out label. It is never
>locked in the error context.

Yes, moved the unlock statement before out without any conditions.

Thank you for the review.

Regards,
Harshal Chavan