From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5273C43332 for ; Wed, 20 Jan 2021 12:44:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8634E23382 for ; Wed, 20 Jan 2021 12:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730414AbhATMlW (ORCPT ); Wed, 20 Jan 2021 07:41:22 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:42418 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727325AbhATMIH (ORCPT ); Wed, 20 Jan 2021 07:08:07 -0500 Received: from ip5f5af0a0.dynamic.kabel-deutschland.de ([95.90.240.160] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l2CCh-0006rZ-My; Wed, 20 Jan 2021 12:03:15 +0000 Date: Wed, 20 Jan 2021 13:03:10 +0100 From: Christian Brauner To: Jann Horn Cc: Alexander Viro , Christoph Hellwig , linux-fsdevel , John Johansen , James Morris , Mimi Zohar , Dmitry Kasatkin , Stephen Smalley , Casey Schaufler , Arnd Bergmann , Andreas Dilger , OGAWA Hirofumi , Geoffrey Thomas , Mrunal Patel , Josh Triplett , Andy Lutomirski , Theodore Tso , Alban Crequy , Tycho Andersen , David Howells , James Bottomley , Seth Forshee , =?utf-8?B?U3TDqXBoYW5l?= Graber , Linus Torvalds , Aleksa Sarai , Lennart Poettering , "Eric W. Biederman" , Stephen Barber , Phil Estes , Serge Hallyn , Kees Cook , Todd Kjos , Paul Moore , Jonathan Corbet , Linux Containers , linux-security-module , Linux API , Ext4 Developers List , linux-xfs@vger.kernel.org, linux-integrity@vger.kernel.org, SElinux list , Christoph Hellwig Subject: Re: [PATCH v5 15/42] fs: add file_user_ns() helper Message-ID: <20210120120310.6tczonwl3rdtnyu3@wittgenstein> References: <20210112220124.837960-1-christian.brauner@ubuntu.com> <20210112220124.837960-16-christian.brauner@ubuntu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On Tue, Jan 19, 2021 at 04:05:00PM +0100, Jann Horn wrote: > On Wed, Jan 13, 2021 at 1:52 AM Christian Brauner > wrote: > > Add a simple helper to retrieve the user namespace associated with the > > vfsmount of a file. Christoph correctly points out that this makes > > codepaths (e.g. ioctls) way easier to follow that would otherwise > > dereference via mnt_user_ns(file->f_path.mnt). > > > > In order to make file_user_ns() static inline we'd need to include > > mount.h in either file.h or fs.h which seems undesirable so let's simply > > not force file_user_ns() to be inline. > [...] > > +struct user_namespace *file_user_ns(struct file *file) > > +{ > > + return mnt_user_ns(file->f_path.mnt); > > +} > > That name is confusing to me, because when I think of "the userns of a > file", it's file->f_cred->user_ns. There are a bunch of places that > look at that, as you can see from grepping for "f_cred->user_ns". > > If you really want this to be a separate helper, can you maybe give it > a clearer name? file_mnt_user_ns(), or something like that, idk. Done.