From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MC2Qa9ZM" Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30B2E10C0; Fri, 8 Dec 2023 08:43:24 -0800 (PST) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-77f48aef0a5so68807785a.2; Fri, 08 Dec 2023 08:43:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702053803; x=1702658603; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=W2xmBI6l/MRigs2qcRLIfKFKtDGM2v75E3mtvHqRCsg=; b=MC2Qa9ZM4DXAGDa/+6ppKt4Xpe73i7xU5i33UASeM99ne8DjchNursPOiFaSBICVc4 VnZgr+yYeaSwC+wHYzU9Yb36IKMcCaXTtxwZJ1sqVQ83rKwazyC8Zr2zxO2kBaOPjbPg SJ+I6UalWSSmxM4PoQgJxIF+VAONg4eL4x/SEbLyClWJfvkrDPNbrkUTE6o95xzftGxF 8BfpfN7WguXgIf4EqRSVJfyiSVJIVvkvBiByorde4qew6LnVtwPwWMN8p5rUcxx1Q4So OB1pdvMzpn0DoLyCoXy7IdC2cljZ2iZFFCqEb8RtyeEiggWmX/IZtbmERFVOw6qotb67 /IAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702053803; x=1702658603; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W2xmBI6l/MRigs2qcRLIfKFKtDGM2v75E3mtvHqRCsg=; b=eLYFWPpYFiZcLqzVD4kQOaRK0eS/mD+gpQ1dtOiqZvI2DfBqbexd1v3n/eLC6fO2lo EsZmtnxHCNi7VMKnNb02D3BVcWRoqjnDrLGbugttC/IrYQuYYEVUmLj8gmS1iv3fMlam Sll/aCOVeCPQVCS0o4POI6eDfKL+UtPWLxNMn2EN2NBznJf2gQANyKliliTjkQZgmzhN cP9rcKX3bZRNs2UO5FwVfbb+cwhFOurcNhOEdnUErzCEKJttWB01qYvHHBkw2Okf6Sc4 VVRclx5eNCxSgqWxjxP6bdIT/px9MCtv3BjyKapJly9+SooHBjKIhPT4E0lhs5vIqdUR x8uA== X-Gm-Message-State: AOJu0Yxq5IZ8Mk/r2E6F9qAKtXwsiNP0PsjKixzbE3Mg75tBKQmftVXV 1yoXKysoNXzS89wJvTC5N0k= X-Google-Smtp-Source: AGHT+IEMOz970vAIG8DxK4T2yh2+WraPteOycduxnsty4R7dX7DngxnM5LsoneUyFj/oXZERR6tzDA== X-Received: by 2002:a05:620a:480c:b0:77e:fc1c:97d8 with SMTP id eb12-20020a05620a480c00b0077efc1c97d8mr396826qkb.36.1702053803249; Fri, 08 Dec 2023 08:43:23 -0800 (PST) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id tn24-20020a05620a3c1800b0077d660ac1b6sm819532qkn.21.2023.12.08.08.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:43:23 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 460D527C0054; Fri, 8 Dec 2023 11:43:22 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 08 Dec 2023 11:43:22 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudekiedgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 8 Dec 2023 11:43:20 -0500 (EST) Date: Fri, 8 Dec 2023 08:43:19 -0800 From: Boqun Feng To: Benno Lossin Cc: Alice Ryhl , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Andreas Hindborg , Peter Zijlstra , Alexander Viro , Christian Brauner , Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , 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 Subject: Re: [PATCH v2 5/7] rust: file: add `Kuid` wrapper Message-ID: References: <20231206-alice-file-v2-0-af617c0d9d94@google.com> <20231206-alice-file-v2-5-af617c0d9d94@google.com> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Dec 08, 2023 at 04:40:09PM +0000, Benno Lossin wrote: > On 12/6/23 12:59, Alice Ryhl wrote: > > + /// Returns the given task's pid in the current pid namespace. > > + pub fn pid_in_current_ns(&self) -> Pid { > > + // SAFETY: Calling `task_active_pid_ns` with the current task is always safe. > > + let namespace = unsafe { bindings::task_active_pid_ns(bindings::get_current()) }; > > Why not create a safe wrapper for `bindings::get_current()`? > This patch series has three occurrences of `get_current`, so I think it > should be ok to add a wrapper. > I would also prefer to move the call to `bindings::get_current()` out of > the `unsafe` block. FWIW, we have a current!() macro, we should use it here. Regards, Boqun > > > + // SAFETY: We know that `self.0.get()` is valid by the type invariant. > > What about `namespace`? > > -- > Cheers, > Benno > > > + unsafe { bindings::task_tgid_nr_ns(self.0.get(), namespace) } > > + }