Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1396588rdb; Fri, 9 Feb 2024 23:41:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVl25lamALFGG8x/UQbLwmWMyrAHmH0AQsUeGKzYFE+Oq+MXuY6XLBa2PqWPhVVIrOQPDndUoW/lEV2jGq5NB/sMp5F5jsoaXCzLquOUQ== X-Google-Smtp-Source: AGHT+IGBFUK8rNS6TEcY6iccFxjubRVItVdVUoyoezrFFUDcKqiscbt+62eQctuxDgCNYKBzOJ97 X-Received: by 2002:a05:6870:9d99:b0:21a:197d:d87 with SMTP id pv25-20020a0568709d9900b0021a197d0d87mr1695300oab.48.1707550910749; Fri, 09 Feb 2024 23:41:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707550910; cv=pass; d=google.com; s=arc-20160816; b=H2cKiE6Lqzzh9blolE6jFiNu7+Q1ouiUR0JCmnBz0m3GWTGrDj1yEO5MQbbmDZFL8M EahBMkVCUXJh3adxblvQysz7mvPmlWs9bXthDNAVSXoW3dI7HpGrgqMeSy5yESV3WiHc bUG9eh/PfezT+ld/V1yU1fLwkWcymYbzebgCFD0J8kt0qmsRUAtbMFYqIZfrMl7mAUQf gyXlx1O6LapLh6tCicHSwZpZZ56a+iFs4aIvqQx14PEobrPaF3wU3jwAzU1xbVE8FMs6 i9a8S+HpQhcwYwWAn0ri5avmnMaFJdN1B1hQ7pmFhkTLBl/ltuu/LUnhzFfuvw82Au10 WBWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=B5Al9ZnS7QlBXv3l9vo86GjjY0RgUDiapvTDHOJYJTw=; fh=+TJgmWGP7TY93oj2Kbt1eUch36vAiw0Zg+GOf53Fy10=; b=jHrSp+r6lC/2WQ/J8wJT1ZiLPLDF3bXkRk4LvK3B8qeiI3A4s5sneeDMTuwi57lsmc XkvrRPOltmE1I/wloQAd7Vvv8gFXnYL9GzmOoCsDg2XVmL0CRfIeWZZbBHvaIwobfOP5 jjCj0sFfIz7XukogSbBE31iveUjdrJUhYdmBQbHj0ReiT7FmGG6x5h9b/f37l7drKb0n h9Gqs3LTYmSTZqWkSUJqsEAN0t1sQZXU/gSNNxrOldRgoHrSll9kVdZZvyXdeMogFp2s 1WoE7cFUpmZAqlb1y33mxUXEuxZhSe05xd+W47N3WfdhcZG4AugIjRQ18OzrK1exRvaX 0HKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=gb9FrysG; arc=pass (i=1 spf=pass spfdomain=umich.edu dkim=pass dkdomain=umich.edu dmarc=pass fromdomain=umich.edu); spf=pass (google.com: domain of linux-kernel+bounces-60336-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60336-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu X-Forwarded-Encrypted: i=2; AJvYcCU1F6C9wmu3gQZiA/FeRXbHEgcYribzpC8zffBvDi48AL3ccSzFqM7jUUAnAYIUoU1PGVRHJvj7EJBrdQ60SnzjaJynKn/uHIKU7iPIPg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id jo2-20020a056a00908200b006dff9452c53si1754344pfb.28.2024.02.09.23.41.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:41:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60336-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=gb9FrysG; arc=pass (i=1 spf=pass spfdomain=umich.edu dkim=pass dkdomain=umich.edu dmarc=pass fromdomain=umich.edu); spf=pass (google.com: domain of linux-kernel+bounces-60336-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60336-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DE0A5283364 for ; Sat, 10 Feb 2024 07:41:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 436DD2E3E5; Sat, 10 Feb 2024 07:41:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b="gb9FrysG" Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (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 B757927471 for ; Sat, 10 Feb 2024 07:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707550900; cv=none; b=WCttqGEeVhotXJ9dNaORjkSStEKl2D4DetQIHgc+tyOxEwThuyQ9vHJE98G4VDI1PrKr7tkQW9Uz/N90zyGhzhzVH6bBgM2y1jq9m2UXrpIKkQK8+tVOMfRfSmvTQqdPdbVXeZnr8B4YfWdpkdy4iDr91/Lr83FMfcC/5XVot34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707550900; c=relaxed/simple; bh=B5Al9ZnS7QlBXv3l9vo86GjjY0RgUDiapvTDHOJYJTw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=pNTjJw/owICQssTC4YsAXvLPjKSEUk380VzHtq9w+FrJS3HAiMhuDygqQZjUAsZ0Wof/2WREzFMryJdMOXwp0NCbAto7B8/CtSP6zR85cUYwU3ylvZlvZwen8au0PA9CjtPgbIXAUqOdNYpVhJo5gY2jG+CMIq8PxGZpD40vW0A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu; spf=pass smtp.mailfrom=umich.edu; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b=gb9FrysG; arc=none smtp.client-ip=209.85.219.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=umich.edu Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-dc238cb1b17so1670195276.0 for ; Fri, 09 Feb 2024 23:41:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; t=1707550897; x=1708155697; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=B5Al9ZnS7QlBXv3l9vo86GjjY0RgUDiapvTDHOJYJTw=; b=gb9FrysGKkvT19tkjG2QIs8WkRCoiMR9LfseiFCMAYUUztoCET0nbec3vQGCKHtdhG rNnaHyzLtt3XdiWpm94mhBNO9B8gdU03eI1Mgs2Mx47ryF9+vT/B/HhE4UPuWaFiHe7K s5Y0SNeM0w1ecZAPtnABVx3pS5u0/bFkSWwph0mmcRfo3bT7pmVhluBdr9pFFzxyuQil nhV42JfzGDvxJ2btM4cmK0OPcAGjEpxWn8Vf1LvgSH8XRPv6l33yPxcPA9AufSh6rqHm WSKA4VpsUkBKm9/ZDE+IR/pZL47OiAPskrxiA0mLwBa5Q/2rHzIcqgzXLMdg1Ral4djn uy4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707550897; x=1708155697; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B5Al9ZnS7QlBXv3l9vo86GjjY0RgUDiapvTDHOJYJTw=; b=hjx029cqSkL/qzPWFP3NI0CE7+zrycBY09q50cxJuVpxqZv8TZV5Cx0TWdJizWZeME qS9PaZOa5RKbhlGqjVjNJ5vJmJWbcCP3utGxDtvyv8DTaIccZvAWdhJ3St6qQuTqKqro laW+LV+4IJbDz9CTq5SxGIdM+OIBsnwTN2ayElvZaeWxtJCJhSIotJFFwnvv2m8zvfN2 ZzkMyQTqyqkAfwVA4fQIYBUknYSObzaltrf4Wdev4rJPnwH3SQ2jkhHOBTmp7tDNpeyx Qfr0jBXxLY/9PmnkITC5bk1xbnkWTW9sPbFo4PHRKkIB4h4h8EZKM0LGQNaEFd9dGsrW h0Tg== X-Forwarded-Encrypted: i=1; AJvYcCXsKnyPklGTSUROZoxykoQIC8ItdZRhpVzZolheWexzVCRE5V+a4jQaSINC5LCHykgK9yIhrqpP+p5Di93ufyKrCB/BuYQYQjdER8RW X-Gm-Message-State: AOJu0Yx9igxhu/I4AhynrIYTEnczDSZGQOqFN49th8zKa/t+dR3G5gTt lYW1jdXQplnz/+JZ/bKJfpypTfvVRgGdxQmJGgH9PQvQt2DEGagPPEBRSUd8Mfg27d+CeLlbnN6 VzlkoBhFLNCmaH26BqyoynwbCeVt30SZTiGpQAw== X-Received: by 2002:a05:6902:542:b0:dc6:6307:d188 with SMTP id z2-20020a056902054200b00dc66307d188mr1258983ybs.25.1707550897730; Fri, 09 Feb 2024 23:41:37 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240209-alice-file-v5-0-a37886783025@google.com> <20240209-alice-file-v5-6-a37886783025@google.com> In-Reply-To: <20240209-alice-file-v5-6-a37886783025@google.com> From: Trevor Gross Date: Sat, 10 Feb 2024 01:41:27 -0600 Message-ID: Subject: Re: [PATCH v5 6/9] rust: file: add `FileDescriptorReservation` To: Alice Ryhl Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Peter Zijlstra , Alexander Viro , Christian Brauner , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 9, 2024 at 5:21=E2=80=AFAM Alice Ryhl wr= ote: > > 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 Reviewed-by: Trevor Gross