Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1397136rdb; Fri, 9 Feb 2024 23:43:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQW39fAkkS3guCp64NXbTCetZJtaw9aZzQfY2VhNh54uI6GyCCyeaUDS0Qzac2hhEpn/wP X-Received: by 2002:a17:906:68d:b0:a38:5de8:dd80 with SMTP id u13-20020a170906068d00b00a385de8dd80mr877115ejb.6.1707551021615; Fri, 09 Feb 2024 23:43:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707551021; cv=pass; d=google.com; s=arc-20160816; b=rSfyodjafo8ZN4gDSl6U5coth5T7ybZ7f102xJy5HjSn6r+EQfU9R//uTmFf/7Gjd/ J0wCygXzLFMpjvMQUhbH6spTfxpX0fVL87ImJAQ7G63+pOPQNzpgUCdle9Mi2Hjl7GsJ 9sa8SE6A+RDAIXFe/KuFRB9mOdoMadOGzmziUZ/CP8m/TA9uRpU1oGJIaqXJA8sR8kxL s6/gOQ2B+47GkjWvVgTEJ3vC1JnnRSSXozPe2o9H8Z1aM9PVxPjNrKG58IL7at+Obv9G ZaUGZu/D470vbhU/40qz5YkCKTJkiuDszNM80sJV4pXvrujJP7GOphjNN2Z1PwMtxZSF laMA== 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=OeBl8V4xziTqeBvkNb4bBS2gsfVXau2tJAbBS4r5lbM=; fh=I71xR0MMUF/QwLB2+BWsyva2X1yvwVxmmS2qgUx7Zy8=; b=ntkqeYWLjJaoaoRHMjUQoAeibKDuJHOalcdBHvf5QPSZxykvHQb7HXD2z8X+hfX1Mo 3hZNyH+5XZgvJ6Q7OMDvXF/TvF/hdmIvwe7Idyz5Xe2Qj9aVW/h4HLjkk4Zl9TKGNYz3 T3JR7Oh85T9CMhZyoHuU5qeAbMmOBCCbH14LFxqCkB1ayeUMvm9JMJBer0bw5VulqtRu GiFnH3K+5YyydbgacCE4FRW/6pQR52fy/PMd2XpHTqUL7wNsi7Yjq64l49tJyDIYxLX0 qUNGUyRKCVbo26kHaQPFa2r+8MkzFerhGtzRB0iX8xVkWG27e+LOP2+4MbN4jfiNpxZX jvlA==; 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=NnXklna1; 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-60337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60337-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; AJvYcCU3bvr/3TtrWsGeCYkSai/6Ui78iQDI/IZEsa9nt+IAMFyc43HbqYCbVXZ7wBY3JBrFijv8+GxfyZ2yVgXdldKo0n5C+kCMAweT1S5eww== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g24-20020a170906395800b00a380d9234fesi1727146eje.859.2024.02.09.23.43.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:43:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=NnXklna1; 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-60337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60337-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 61B581F23C3F for ; Sat, 10 Feb 2024 07:43:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B6443611F; Sat, 10 Feb 2024 07:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b="NnXklna1" Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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 EE67E33CE7 for ; Sat, 10 Feb 2024 07:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707551007; cv=none; b=OTXpLpn7JN4ejw7X7YjXRlSVDI+4Pcv3ksP1MAznJLeW1eLD4nZc9aA740UmjzgQMKnZXDmzu7jEJxPNGBAs46cOx1MyavaWuiTKEENcNmDkUew1PqaXBctrEO5o8LSLu/mqj/JSeu+g7mKPeQL9Vzvxq0zE7xiwm0BKQiqjyyg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707551007; c=relaxed/simple; bh=70bvpWCaiQjXnWwhjEaUPbh89LdTobpAVbcQg6lcPS4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=TU5YHPo0a5rfnHWqwWcVZXAiYBRTfh5EfZKVV/4NEHtMJZEm0Tkwyfj6e+70G6ADJ6RNqDjqJINUvBiAgORW/hyi89Ihz9g5cVwRxIZW7GzyR6v/7tS4+kUH5CTR3K6YRAavDMDwXpfD5hraBagzH6xMw5qJPHuaFrkFbbg1Gw0= 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=NnXklna1; arc=none smtp.client-ip=209.85.219.178 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-f178.google.com with SMTP id 3f1490d57ef6-dc6d9a8815fso1812134276.3 for ; Fri, 09 Feb 2024 23:43:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; t=1707551005; x=1708155805; 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=OeBl8V4xziTqeBvkNb4bBS2gsfVXau2tJAbBS4r5lbM=; b=NnXklna110vETvmOXKPtrZLvPfzGMwLGEQg2+L0/gj9+GBUBUV0jkLI5AZ8ebfcFPd DUjBkQ5lqrpEnluxJQFOrQHfcFanZS6l9voQVVXSgm81sLgCFCu3U+n2wY1F6x0Koswg dX2Uf8X2fDIWCIes7Vq9AeL7tnCJCcmu2cOTmRq4btdLgHOZ5GHBDChllO0yOWU28d0Y xTH9iFdJELfY6kgX/b/SqfW9FMUlRTLbcft3LIN//0dhECaNNjR/DzUgO/3s5jOgbMKn Ca/+Nygcl2e+6iof2JuQD0+QAPP9uR2fs6XQTMlfh7HoJAAGFyZ01002bWsWVTGJPWj0 VnPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707551005; x=1708155805; 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=OeBl8V4xziTqeBvkNb4bBS2gsfVXau2tJAbBS4r5lbM=; b=cbRHrsjreLhrSJ++r/K0aFlg9l4fXQ+QgX7Eer5sjFwhQ+tZierI8QavlPDIXt//0/ 4l4up4TaisHUSlMVMFT4x/3XaXqnGRTV8RRjMVQ11II4tkdlPgm/txT/7WXNYUDkioVP /BjqOMxImruePKKAra0d/mXywr1MVZlxCSANhb8fwSYa38qvTPDbV+TQo3GTevSv71/7 NMycYUYPm5BJDpP6G6TCbU5vHyCyCbFd57I8fdlRmsKXNKqNBogwMgRyATexXCS1J2nH OCjbHTsPbGBbZbkW8rz0EBUA4jiOdvQ6h1EKZsWyyVIfBJSpm/1Xd0nrwWxFDtnc7QRq 55bg== X-Gm-Message-State: AOJu0YydZ+N7EBUDJ3x4Ogm8G4MK9QC+Cv0PY+Y4GMl3+boVN1tGwUc2 j2xghB/SmTeXeIMvj0RG9C0ALbvZ2IV69RPCU79zvGjIIezaAoicikTH4PnoK9Nvyz/mASZe5Pd ofpYLge2M598EeydJS1wfsksoDUrKkmdvyCyPuw== X-Received: by 2002:a5b:c4a:0:b0:dc6:c619:61d8 with SMTP id d10-20020a5b0c4a000000b00dc6c61961d8mr1423355ybr.35.1707551004854; Fri, 09 Feb 2024 23:43:24 -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-7-a37886783025@google.com> In-Reply-To: <20240209-alice-file-v5-7-a37886783025@google.com> From: Trevor Gross Date: Sat, 10 Feb 2024 01:43:14 -0600 Message-ID: Subject: Re: [PATCH v5 7/9] rust: file: add `Kuid` wrapper 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:22=E2=80=AFAM Alice Ryhl wr= ote: > > Adds a wrapper around `kuid_t` called `Kuid`. This allows us to define > various operations on kuids such as equality and current_euid. It also > lets us provide conversions from kuid into userspace values. > > Rust Binder needs these operations because it needs to compare kuids for > equality, and it needs to tell userspace about the pid and uid of > incoming transactions. > > To read kuids from a `struct task_struct`, you must currently use > various #defines that perform the appropriate field access under an RCU > read lock. Currently, we do not have a Rust wrapper for rcu_read_lock, > which means that for this patch, there are two ways forward: > > 1. Inline the methods into Rust code, and use __rcu_read_lock directly > rather than the rcu_read_lock wrapper. This gives up lockdep for > these usages of RCU. > > 2. Wrap the various #defines in helpers and call the helpers from Rust. > > This patch uses the second option. One possible disadvantage of the > second option is the possible introduction of speculation gadgets, but > as discussed in [1], the risk appears to be acceptable. > > Of course, once a wrapper for rcu_read_lock is available, it is > preferable to use that over either of the two above approaches. Is this worth a FIXME? > Link: https://lore.kernel.org/all/202312080947.674CD2DC7@keescook/ [1] > Reviewed-by: Benno Lossin > Reviewed-by: Martin Rodriguez Reboredo > Signed-off-by: Alice Ryhl Reviewed-by: Trevor Gross