Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp213232rdb; Thu, 30 Nov 2023 02:53:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFawafzT6LXkraC23dwF/PxmSBnEMgK/Y6OQgmiAEwCTf1aIIvJEiFx5wjsqTIG5okj+aou X-Received: by 2002:a05:6a00:189d:b0:6cd:9033:b3d0 with SMTP id x29-20020a056a00189d00b006cd9033b3d0mr15184168pfh.28.1701341604253; Thu, 30 Nov 2023 02:53:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701341604; cv=none; d=google.com; s=arc-20160816; b=Gk29ku3M12XiefkuKjqTeZQz8LKCdT3qXNyczopzWrtoY1zOuJ7LCEb0DdISuVnSkc fnhyglqX0r8Iwxpl74o3tddcYExGVBxqjuBQs76oHLLOHtRE3Ag0Zpsy9xlgXJ37+Mqf Fm91ahkSqV8nVsSBT3HyPal9v+ZHaFJ1r10zTJl+ouVd2rvAOEHd9yxlYh6BfEMhtpo/ 0L6l5YuKWMhytz53q5Cww072rnkdS+XcWcYHLHMQsfOa5w/ln7txWMfwR94qoGhU+j6v 7nsHcSJFxgghQEI/pqVNzWb+UF3QLF/RzNSpALomvHmtTpiitdIDp4tjlm3GCNqFm8yB HO1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9HO4sjOh5Gyf5ziKaIlQ2rYgPhMbUhLhZFY+JPo1YE4=; fh=RSd+TZy+/ERHgQwZJxQcFDN6ZwblMaCj09CeqL1TqaM=; b=R3VgY46Pr3NwQO3SHm2X33giSEL/l0d3oIE7I4f8dhW0OqPA2eH4X4aozkbK5ytrIe y1brbdxqyRSzkKe9VRDIy10BdNyoJsggtYIwHP8ICUy6r34iRsmRJS7CHHgEYuGumTx7 Wn59UcMS8aR0IKgzgYFTKPYYTcv3zDSWsq8R38rTNSRwVgJ4SMZ/sAx37FU0fZRca+5R kmy6toLdno1+M6iNeNBCrlytnQEBOJuiw+bBAzKESTSqo7EXQwy2VTvFGJyAXpgND5GD smIV6i+L+6jexygLyi4w4xEV8voqhf93xKLrcy8zTU0bnPosOo2vhMGhx0V3K2d1mH7x efyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nxgq+smu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y16-20020a656c10000000b005c24fb6927csi1156230pgu.656.2023.11.30.02.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:53:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nxgq+smu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 79C058029AF4; Thu, 30 Nov 2023 02:53:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345070AbjK3KxD (ORCPT + 99 others); Thu, 30 Nov 2023 05:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231784AbjK3KxC (ORCPT ); Thu, 30 Nov 2023 05:53:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E74D0D40 for ; Thu, 30 Nov 2023 02:53:08 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7729C433C7; Thu, 30 Nov 2023 10:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701341588; bh=8XkaVRCmO2JrQF4/dXotopuTsQp9i+OgT5+rIs7i4Gw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Nxgq+smu5i9vrVSHRNyc4tSnnk1V+SQBcysfec0SgCiyBnnZiKxpVG/yENQAGdJHS P0q9pkQAc1X8rRKYv/JLNR5EDc/mQXLUp+U6IaF1oI32BXTNRgo048TE8o7dY+8Oe7 OOYs9gagAX88y/maW+iiG9baEcJWSbGf5ouOq7Thf0Epn8Rr8lOMoPQv2dyMjrVDY6 rDBmjYCyUVtM9jnAB7t8BG63/q6HrfRVikfqjUVEZHmXbEEOazWx6yali03PuUE4Mo cluCgiEauUfrj6iM/fyEGAth/qfmFIpsXFA0k5JPUw/HWtjPPMmGnIr4kp/odUrS3n NNNzR8mFh3wHw== Date: Thu, 30 Nov 2023 11:52:59 +0100 From: Christian Brauner To: Alice Ryhl Cc: a.hindborg@samsung.com, alex.gaynor@gmail.com, arve@android.com, benno.lossin@proton.me, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, cmllamas@google.com, dan.j.williams@intel.com, dxu@dxuuu.xyz, gary@garyguo.net, gregkh@linuxfoundation.org, joel@joelfernandes.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, maco@android.com, ojeda@kernel.org, peterz@infradead.org, rust-for-linux@vger.kernel.org, surenb@google.com, tglx@linutronix.de, tkjos@android.com, viro@zeniv.linux.org.uk, wedsonaf@gmail.com, willy@infradead.org Subject: Re: [PATCH 5/7] rust: file: add `Kuid` wrapper Message-ID: <20231130-neuordnung-matetee-7aefa024f80b@brauner> References: <20231129-etappen-knapp-08e2e3af539f@brauner> <20231130093603.113036-1-aliceryhl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231130093603.113036-1-aliceryhl@google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 02:53:12 -0800 (PST) On Thu, Nov 30, 2023 at 09:36:03AM +0000, Alice Ryhl wrote: > Christian Brauner writes: > > I'm a bit puzzled by all these rust_helper_*() calls. Can you explain > > why they are needed? Because they are/can be static inlines and that > > somehow doesn't work? > > Yes, it's because the methods are inline. Rust can only call C methods > that are actually exported by the C code. > > >> + /// Converts this kernel UID into a UID that userspace understands. Uses the namespace of the > >> + /// current task. > >> + pub fn into_uid_in_current_ns(self) -> bindings::uid_t { > > > > Hm, I wouldn't special-case this. Just expose from_kuid() and let it > > take a namespace argument, no? You don't need to provide bindings for > > namespaces ofc. > > To make `from_kuid` safe, I would need to wrap the namespace type too. I > could do that, but it would be more code than this method because I need > another wrapper struct and so on. > > Personally I would prefer to special-case it until someone needs the > non-special-case. Then, they can delete this method when they introduce > the non-special-case. > > But I'll do it if you think I should. No, don't start wrapping namespaces as well. You already do parts of LSM as well. > > >> +impl PartialEq for Kuid { > >> + fn eq(&self, other: &Kuid) -> bool { > >> + // SAFETY: Just an FFI call. > >> + unsafe { bindings::uid_eq(self.kuid, other.kuid) } > >> + } > >> +} > >> + > >> +impl Eq for Kuid {} > > > > Do you need that? > > Yes. This is the code that tells the compiler what `==` means for the > `Kuid` type. Binder uses it here: Ok, thanks.