Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp327028rdb; Thu, 8 Feb 2024 07:08:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGq9GCiM+zia0Hz95vu9PZp5owtUcQT98JYD0IhedDxymn7DPlbaDvLMylNMQrNIs8p9wjA X-Received: by 2002:a9d:4d10:0:b0:6e2:be39:a265 with SMTP id n16-20020a9d4d10000000b006e2be39a265mr1465211otf.14.1707404903908; Thu, 08 Feb 2024 07:08:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707404903; cv=pass; d=google.com; s=arc-20160816; b=aJc/jnpZKcTWEi4ZEbbb8BPRVs/CLpmjOD7as1GtU/3Anfqtson9tJxJnhhZIMnpYK c3hHoWrSNR2+JaJrydtr+3+eXGay3VD99KfVpi3brlmzzJBuVHV7iG54IR9LIn2BaQH4 2QmY3GBlTGiM7gSmTUzfCm/ZXigMNNPjMWWUc3XzQohISzAYTQVcwwRg8QUha7Hb6gOD b+GZp/yuBslFIyI3IsSCxhUYelRCf/tqZ9KriJ0u4M6ciWx62JXps9qmKOusGTzSe7M1 7Ua6ZG8hEb8H/IsOK5QWQtIXyr5Pj3Yd+w3IBpQIHh/I8yhqCL95oaB2HkS80ecFIX9b AB+w== 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=GaZbU6qRlbhHeLigMFgS8QR4NIPfAZTvoIj/0tP4h70=; fh=MZfT500rSbyZtgfAKgROtrhrsEOVV/GdpD/g+j5lILU=; b=cHo8io2PNwhw9BOpMsCtn//JqNoLGJMjRH4JFIWGibOGBeDVMmBJIz8tutr2TBCwg9 VaM3xikMOex5VSONNTmK5opqM6BybnQbllDuDIrHMgMCx0liF7kH1HRk7czw5SC8PybY tRelTTjIUS3FN5MyEijEJ2Ma8VSYbc+NT1qzDmDDQPhes+GPZWeKQW1sPDzGwG4ELZTH 5OMt07t6az/FfNPzTx1t32AaIO88c+y10pi1XtPm86PmFNbg4/YmXrhLgjmfbG1V5fxp kSQF+3G8I3QKfjUiRzcGsEA/E7qQCaeqPBdZwsyH9NbSKUTYeFLmcV3yYLHYAHPkiw+5 oeDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JKT4NrCV; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-58267-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58267-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXzToUgLZuiMDZUKogV066u+WuFGVMfn4MsMrRVOIWOh2xjWMXdDkKJWUguFVHaHu0qVeYK2LSFH74f9Nzu7407apWts5Y7z1Ed4tRkhw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m25-20020a9d7e99000000b006e2c5b60d60si232536otp.15.2024.02.08.07.08.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 07:08:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58267-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=@google.com header.s=20230601 header.b=JKT4NrCV; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-58267-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58267-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 8536A283A67 for ; Thu, 8 Feb 2024 15:08:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4A157BAFB; Thu, 8 Feb 2024 15:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JKT4NrCV" Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com [209.85.222.42]) (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 86D1B7B3DF for ; Thu, 8 Feb 2024 15:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707404887; cv=none; b=bKYmrjLOeYYXYDGsB6InGeYIQi6b5rVeY5PiK4Ie4kkiRUVmrsutRVcqAFcS8WhR1otaO1gbCH8YrmDlmU2jQu1dRi5j+xv3867ZL3MbAmHUg4CM2Z6bKP/IogLjJLQlNb9Qj9i+h7k7KyYhPyMYoKTasEb7kSb7RaQcpyHzGsU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707404887; c=relaxed/simple; bh=B2X73Y7KSDr68vQod+XguhQ6ZTVc/cqFBBByyo+cBs4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WBWRycuKf9xQdbzypvoHGhLWlsaveyOYHqx6XiKAs3SfneVEW7QiCyCb+smilKAZiTYjQpoIeW6Wu0AzGSUuxwh74GTDhZ9BT1//H551BxVMLM+WbYwWtX8TjxZrl/iKX3x8+ew/rm8/uJqyN3Gai4hW+Mcc/kiYqyCRtpRJZNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JKT4NrCV; arc=none smtp.client-ip=209.85.222.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ua1-f42.google.com with SMTP id a1e0cc1a2514c-7ce4512d308so541803241.1 for ; Thu, 08 Feb 2024 07:08:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707404884; x=1708009684; 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=GaZbU6qRlbhHeLigMFgS8QR4NIPfAZTvoIj/0tP4h70=; b=JKT4NrCVNu3FaOn28qUwje2/2IwBjqUkvaEZiBPrX71a4Y0Gj+2xXIJJpo89D2bieO PQlV4bJp+RcS47y/yq9LzZv0JB33YyWwIpcpBYZN9OH97aXkyi5a5NxU+XOufNkAQFTj Ey93AgZcPvXmBGtTzBRiwbBBrUWjzqNeAhVmTdfa37/f8y3HGuH5QYJQKHF/7R3UYSyP YqGeRNjK+5eATFheGBHfNylkCTRZH75I/BA9bEtoYhJ+7PAsXF+F2DhelhuTnsA7BnoT gwbh5I3oKy+E9FAole3uRxuQacVyORavKp/5NP6tkMogI/k3r3UKQ6FjFYsef2INkRtL hFow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707404884; x=1708009684; 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=GaZbU6qRlbhHeLigMFgS8QR4NIPfAZTvoIj/0tP4h70=; b=A5HnUyxYYXzLnTaHkAqpDA2+Z61s2nEuRpp/o4yKUo3ZJvsHcwPlT90zn5mdN/shFX aX3UDyun/+znfc54Huh63rkY2aiIIaTnfItH3egaDUEVSnYwqNkkHw0X+BK18oBNn4l+ 79kK4SWKbO+Cgls1qtQ17MAUlOPda/JXRUsKNs23d/Evtgo1ERmdfZt4chY/gxW8Lf7P PRw8/7/S48hqA5KEYXDN6b0T7bBwBoMyIFS58au8JS99wMSZfC34/cW81DYXKjrkX7Qa ERriw+1mw592lLQNrUrVhuKrT4CSgf1N3ZV50EYUIi22DjYqD+ibRvKPAVRFtRidF3uQ TYyQ== X-Gm-Message-State: AOJu0YyWqjwCGTQ+sgTSdWbZMzx9vgmt8t2MQhr2b7OyASk+KthIuYr4 L8RDsS0L7ZLCafOFQqg7vCprYag1UmEheXi0kvC3YQH+Ps1d4VEXzqLGcASMFYGag5Kkuy2sCB4 xPdG2E6BzjTz3ec29SMkvJ7UAkR1vxBvQoBzC X-Received: by 2002:a05:6122:208a:b0:4b7:49f9:c6f4 with SMTP id i10-20020a056122208a00b004b749f9c6f4mr2534429vkd.4.1707404884308; Thu, 08 Feb 2024 07:08:04 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240202-alice-file-v4-0-fc9c2080663b@google.com> <20240202-alice-file-v4-4-fc9c2080663b@google.com> In-Reply-To: From: Alice Ryhl Date: Thu, 8 Feb 2024 16:07:53 +0100 Message-ID: Subject: Re: [PATCH v4 4/9] rust: cred: add Rust abstraction for `struct cred` To: Martin Rodriguez Reboredo 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 8, 2024 at 1:35=E2=80=AFAM Martin Rodriguez Reboredo wrote: > > On 2/2/24 07:55, Alice Ryhl wrote: > > From: Wedson Almeida Filho > > > > Add a wrapper around `struct cred` called `Credential`, and provide > > functionality to get the `Credential` associated with a `File`. > > > > Rust Binder must check the credentials of processes when they attempt t= o > > perform various operations, and these checks usually take a > > `&Credential` as parameter. The security_binder_set_context_mgr functio= n > > would be one example. This patch is necessary to access these security_= * > > methods from Rust. > > > > Signed-off-by: Wedson Almeida Filho > > Co-developed-by: Alice Ryhl > > Signed-off-by: Alice Ryhl > > --- > > [...] > > + /// Returns the credentials of the task that originally opened the= file. > > + pub fn cred(&self) -> &Credential { > > + // SAFETY: It's okay to read the `f_cred` field without synchr= onization because `f_cred` is > > + // never changed after initialization of the file. > > + let ptr =3D unsafe { (*self.as_ptr()).f_cred }; > > From what I can see `file.f_cred` is valid from the moment `file` was > initialized, worth to notice too IMO. That's what it says? Alice