Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1598350lqt; Wed, 20 Mar 2024 08:33:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWfYz74g/E9OpggX6dSHKZTxzz4NbewtwSbVbe0JbBWBvIZk/F2lWKwzXwZ6dS/8c+1rwQ3rv4wOIuJ4vUO/+iTZz42GcK1zodr38OmQg== X-Google-Smtp-Source: AGHT+IG4p0mXxIpVSZgELVeT4PZnPgudTpErRBBxY8xJT231jOL84EvUsFbug4UpVq+LGB1m/BGZ X-Received: by 2002:a17:906:f28c:b0:a46:bde9:c868 with SMTP id gu12-20020a170906f28c00b00a46bde9c868mr138936ejb.26.1710948814217; Wed, 20 Mar 2024 08:33:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710948814; cv=pass; d=google.com; s=arc-20160816; b=Pkgq/rM0NwTm+Ty+h0gr/rT1irPrlLGCklRmbLrVsQ6iuLdPNSapNEMDI16ETAxe3L FXXYlVoxLj66utw53kz6TaZ5YalRfUVuUD5frM1HbnjxrV4rtPktyKUzDKi9H43zxYs1 WD/WLqiSt+jo7NYHWA3h+Loj1VFQkgwaq9SpitEBzV2rGW957rZS+YziPkrTFMCg01p6 Kp9xtUaNjV74bTRxCgq3zVoWUfugGUCHrcC1G+zI5MlfMhDbzcI/3sfv3co1VKRAivd3 IMSHcJ4FwCc+cZFJEsq6KMp1TyfxYhVYXpJuEm8nX8FXrdKHSURBI5FdLa8UDXDJQmNT CdUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=F4w2gC1zJ+EPfLeSbLlyTxmNSfcqzN3Dv7iG9IJoiAs=; fh=Pz+LhpCMsJrlR/A+6e6dZNsJoyWD7btSVo5+NQ5aHo8=; b=ZsQRd6LENyF91p7jeMztkKzFiDEQ+i60kvHHMaFaa+F1As05O9UiPcxzjM/fThpH9n AYH03tk9Y9zU3BvrZpNhV4IfzV+q7cDHVnfMM4/x+eSN9gJV8eJnqrUjERUHbBofu0oB i9NYyoKIwlPiyJaEsTQdis2527YnbdhoF2MJWLyQ1o1jiVu6TaD/kZfR6Umxl88Zk2E8 zhSLK4dKrFFCT6w0yqbuJewKUQlQDIKguPCbOQ36S0a1wTWdlSDP/eAVsb3KU/wAUqdl Xo3acSEvaEvQjyvK8kja09rqzDsx77o55thWcbfU9gwmf6CZG5jacWCE5K8mRp7yWoIh w96Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MR87vbT+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-109106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109106-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n9-20020a05640205c900b00568b44a643csi5445657edx.239.2024.03.20.08.33.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 08:33:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MR87vbT+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-109106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109106-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EC4931F22E43 for ; Wed, 20 Mar 2024 15:33:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7B5A54BFA; Wed, 20 Mar 2024 15:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MR87vbT+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1FBF14A96; Wed, 20 Mar 2024 15:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710948789; cv=none; b=vEPMeeU5zVSgi7WqAnaaEtVfx1C7AC6O6Q7l2LYdEx8RDBnmeO6eGsAmKfNT0RUEnk1/PKa1a/+841MqgN818P7or0Yj32rodavJOxaAp/NY0BVevZJ5+2YYlRR6cENWJ3ckNyZYt4aHVel1BOUOSDTzJcOlxDxfNUnf3VMTtWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710948789; c=relaxed/simple; bh=g0nzjCQBRPotfAplkOEZ49775DmzGb/Il5MwgJUi8xI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GZyvJCFe1n5QZg0cIw+SSiDi8JLViJ/AaFLHVZm2IctQKocYhm0KM+E+9DPF+AECS4MpHlNypyv+4mI01nsO9mWDXOzLPVsisNmMDMBPZ2gqpS7iEOSygS5wlCw4mcI2C/44VoW34KXGawG3ewMZsdyZAYCg3J+4kW6ct5jISbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MR87vbT+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA874C433B1; Wed, 20 Mar 2024 15:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710948789; bh=g0nzjCQBRPotfAplkOEZ49775DmzGb/Il5MwgJUi8xI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MR87vbT+lZhz1UVK7v/lmHTX5vlSQWodzAC4mrQmpB1cSduWOzLnVhrODFyxiXAy9 cmmr2OV+FTM50RZ/lt2qC+DQIjCxQQhIqoLq2V2cNOnmNofwcQWBCUosxkW7OQ+fT3 37t9oK8WVVGtLfqqFeFU8uXWyTxKhz1L3Ytr6+A0fUtY/94sJhYhNi6msYPyRplPDA rKZGMWxa6MSYmo4UIe25PQIdKi5enY0xTfwjG3wWlKVJGAhzjNt/d2AAd286jyjCp2 xoHIFOYbAi9fA7V0r2/IQIs5hBPTdPMAtvB3zwHTxE1tZ4z1yowXgQhezUPbUROUrY hxBWCI9AlXA4w== Date: Wed, 20 Mar 2024 16:33:01 +0100 From: Christian Brauner To: Alice Ryhl Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?B?QmrDtnJu?= Roy Baron , Benno Lossin , Andreas Hindborg , Peter Zijlstra , Alexander Viro , Greg Kroah-Hartman , Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Dan Williams , Kees Cook , Matthew Wilcox , Thomas Gleixner , Daniel Xu , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org, Martin Rodriguez Reboredo Subject: Re: [PATCH v5 6/9] rust: file: add `FileDescriptorReservation` Message-ID: <20240320-papier-seenotrettung-c5eaeda87478@brauner> References: <20240209-alice-file-v5-0-a37886783025@google.com> <20240209-alice-file-v5-6-a37886783025@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240209-alice-file-v5-6-a37886783025@google.com> On Fri, Feb 09, 2024 at 11:18:19AM +0000, Alice Ryhl wrote: > From: Wedson Almeida Filho > > Allow for the creation of a file descriptor in two steps: first, we > reserve a slot for it, then we commit or drop the reservation. The first > step may fail (e.g., the current process ran out of available slots), > but commit and drop never fail (and are mutually exclusive). > > This is needed by Rust Binder when fds are sent from one process to > another. It has to be a two-step process to properly handle the case > where multiple fds are sent: The operation must fail or succeed > atomically, which we achieve by first reserving the fds we need, and > only installing the files once we have reserved enough fds to send the > files. > > Fd reservations assume that the value of `current` does not change > between the call to get_unused_fd_flags and the call to fd_install (or > put_unused_fd). By not implementing the Send trait, this abstraction > ensures that the `FileDescriptorReservation` cannot be moved into a > different process. > > Signed-off-by: Wedson Almeida Filho > Co-developed-by: Alice Ryhl > Reviewed-by: Benno Lossin > Reviewed-by: Martin Rodriguez Reboredo > Signed-off-by: Alice Ryhl > --- This looks ok to me now.