From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B243EED8 for ; Fri, 19 Jun 2026 07:40:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781854826; cv=none; b=if1L6e+RCfZAttT/Ud670WquugxbBW33Y3sjl68jeOe6kznoXbD3uwT3aEvexRtONto4mjnC6grdQhvz9o1irSvdAhQdOs6+PFRTXAw8wnaXNJfoLSHS/Y/D17HVEyOY+iAr+ajtkYwcK5dGNQC8Q+b3ESICru+XvXk+04THE4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781854826; c=relaxed/simple; bh=2Qsm7oOOrR36fFL8O1zr2PwgV7uJ+NhGTXCp/hPxneg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k3v/UwWGCNi3GlxzWGf9J4JAAU74aWNCE2mpLVF8d/2ujbQtoTC5UQZzOknziHUJdZEvWzkW4hYepVfc1uy25gaGODtSue6Qt/obO7+3NqchDshTD3rtiDVDCauArMnDYbuNjv2Dfb/XbJy7BenyGOTYjxUtZw93hU44kyaGqb0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=qHElcIwv; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qHElcIwv" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2c6be9cd89bso8351295ad.2 for ; Fri, 19 Jun 2026 00:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781854825; x=1782459625; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u8IoIRgPFus0dtAjx1VIV2D6Zb5vLDM4e0T5cbfAtys=; b=qHElcIwvelE2WF0B6fksaKuU3/ZKXYAsyjV2jpxUl/YAsx+TCMrLkmvpkzGEAHEq6B fiQb3mtrdaksHagik3VdrLG5etilCWX3To8n0KE2jwLHdJnNpbVLywB1VRAR5HUhn/IC OapyedOvwfYWc3H9/qezkuBWmXeeKoaq4L7/a/+WSD4kOhtwGo7TWTXIZPl4WFEKUMaG oBCsY6ZMtEPVQQtEGocqHUGghbhAxnsrh2UwNwxIXyZuBH8VskurEz9yZkkGmudSglLC UKvyKJIlRkmGSMuBGe706fSn0q2LjfNZsJl/cTbzkSQq1WXCUmjeA4O/df5NqvbEyvC9 3c9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781854825; x=1782459625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u8IoIRgPFus0dtAjx1VIV2D6Zb5vLDM4e0T5cbfAtys=; b=ZqUj2Utr1uAEwzQJZHAGX2yWTdfyIivO1MisJr26dyqJcMFVtou9OtrD7fhyoks0+d gDL79hsHAyPn/DIYyxB+6qlezFfIwTbKIXza2fqynMEBviNEp7Dy2k1msgvZM2lhJ6X1 EdFEuoWil2Abm9tFw+QaGLs86RsFWhnY7Sjd1/hEEN8ALtV0OMj9fWWbLSVW/YviS0bm DKOpDXtNNMbZpzcGrrTP4NPXqYNJGSVF5S1vE+ER50cvm4X+gDKwEjzgrFUF6OJjzqie bRUyhVdr299mmE0LmAEAOgmTxlxbQDnlR2/3qS1hWdcPIhIBWTzeHQpGIAEbezE3UZUQ 1Ayg== X-Forwarded-Encrypted: i=1; AFNElJ9ZjfzDAYrxMjGDo+bfW6+VJoOIuT6SXIAqFni3rrz9Mbv2/+AruWlIDnlnKZmGCRkMjB3Ri05eQ1n2Yus=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+UJ/9UoIHzJGhTvCEGLxmqChZBwNevu7QDap7pPrvVIm/WFZN jaIOBjLocEl3e5ZP9/nqyMA22gCEhzhrlfXGoM+NPQ5BWztgx9oki6u+ X-Gm-Gg: AfdE7cnp+4ZzeFXs9sSKqQMRA28p8tVfnmZds3D97MSq3FBUecdlG0W51jr2L2VpuEr OIgsghb4up4Vf7XceqdUYOqFXu6RAbUjkzCegl0Je843jnfKtuLxvDXsJlfAxN22ms8xQhWh/4e 1GkaD1lXzDfQLem5haL2G/nzb7rKJ4YBiQuxSNcAUJPf9Po6l5ySK3dV7h5/y002SKsxLEIIkmY JKtowY0A+IfvXBOXX6M5kY9D5wBVqtSn5VZWaAL8TSV5McGDPqZJeah7U/KmJcBmHQxCpusJ9vS 00gwo8nVxSwcEwan7JroMeXXWIPYyFucA9dNE90NGivP/gkm+K1FDojud4SAglTUHj2gQUjaAez qlrYp60fTOFcVUFrfJsP2bOeS8gol/+lKD6rPhmBszHDs6iKLT9kjNj2QQXqH5Qz7sUu6cKJcg4 3y27djTIjCLLPerSx9BrtJDJoGnlBBEabq4LXKg40xxEfz2A== X-Received: by 2002:a17:902:f54e:b0:2bf:7b62:a038 with SMTP id d9443c01a7336-2c718ca5fcbmr31211805ad.9.1781854824925; Fri, 19 Jun 2026 00:40:24 -0700 (PDT) Received: from Athena ([58.146.97.175]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c720c0ec80sm14754875ad.76.2026.06.19.00.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2026 00:40:24 -0700 (PDT) From: harshal24-chavan 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 Message-ID: <20260619074011.15289-1-harshal24.chavan@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <87a4ssyey0.fsf@mailhost.krisman.be> References: <87a4ssyey0.fsf@mailhost.krisman.be> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.