Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp197450pxb; Wed, 20 Jan 2021 05:01:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBm0Ps9QARhSmJDo+g1dWUOM1zKAN25sW+6StdF7EPJguJrm17WJi3glnk9PDdI/CYVWu4 X-Received: by 2002:a17:906:4bc1:: with SMTP id x1mr6114428ejv.509.1611147665673; Wed, 20 Jan 2021 05:01:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611147665; cv=none; d=google.com; s=arc-20160816; b=EDA7xPpMQLH2nTPl1wqmDqzZzCdNafK2nLz3WJ8xmJPfldE5tX0rb/3ZnWbEBsRq1d J06NvTYWq2E4FpqGyrWUVD/gJU6aJeNX4/rJxenxZml981AnmVid1ak+kR1ZyEGKVXqD 6WWUbvSjlP0aWi2SWBYxOENwID5mzg2N00AD2FB8FZGxvNv9ABLkQawn43Tj4KddwqBO 5wZhf5aWBqJ0fWHnrwOuEUAGvDQgG8jBGDZ2gEVQw/YT7e7U5GslSWSKj9ZoqC74LKr3 0dHfYHoiAnxVHAtLujxQOGPi+yYxJ4XRk9zmLo1ig56c097a35RCWKnvfHySjs+Ju7EI McsQ== 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; bh=CNLKoHfGJfRQzTGHF4DH2BXGzZnE9sumCain9/a7wmA=; b=sIjXZYi7kJq9aCnC9mfKC8P2v1KLbAAX/5BPkzLptoCms+TA8RTP2wp8j4Oc8LDEry nNgXtD0Qxw3Pdtg1gF2rKZVI1DhRELzvOInHFwTblk5Td69VBqZDiWpU17xMkV6XQeV9 9ih0J2nrSWBn/WSk5mSOGv0nCHfffPeAAGlb3BGUnOdlo4UPDF++LXCKL7scmf9oDSIF cByDEgSsHeRKVNjr2RcFiVdi8N9B9uQbHfy0JmmKq2nmMQJ2jhFINz+oMuvckWFasTm3 aZRTjMMYuJWJVBxnY9QCdWhcYg5u3HwwdtRoX6QAWCUUL1oUoORS7WCIPcuQDf67gNhj y8Cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si798089eds.521.2021.01.20.05.00.37; Wed, 20 Jan 2021 05:01:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388800AbhATM6w (ORCPT + 99 others); Wed, 20 Jan 2021 07:58:52 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:43216 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729022AbhATM2v (ORCPT ); Wed, 20 Jan 2021 07:28:51 -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-ext4@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.