Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2831565pxb; Tue, 19 Jan 2021 07:12:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgP6q0nie9ZlcgBPNNonGii1IXQXBfREZkGiQ4E7KzQXOk+pNQiaAoe/0rH/sN8VHdr0lQ X-Received: by 2002:a17:906:958f:: with SMTP id r15mr3193408ejx.360.1611069146918; Tue, 19 Jan 2021 07:12:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611069146; cv=none; d=google.com; s=arc-20160816; b=tjSiOKuo5AtKxF5RUfMwiUmlFYdwRMqEEZI82OXQvG/x3O6jLhQ1gxV5tAT0dq0Gkj VKZfrqm0pussugZ+mBcWrIjM/Xh0zGhV/smJUJkPDJe7dpQd2TtfgTCXhgDrs753MBZK IgXCnV41Js8ZTf56fSl2NaZeHIsfoMnMk56T8IgNi3uThyj2Ij/R7MXP4ify7JFEfRiO dScM7/6jZ04PnCeQ95NZWvo7I8vje2Lgmawvxso51uRS+xbChdE3PynkBodg1OB1lFyd qUlEQ3Sewuj8dmn8z3e0ogxHGFlU0atyADprtWkx/BiKvd+5hVtKaTBy4jwzyTauRtJT EIdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gOmgvCPsNvi85/TpBsHHlznh/AXeaDwbv8LGPCZK7GU=; b=kabY2b9zQSXRitHOfv5bljXNsaOTLpGT2QFkFfcHc1Y7hlIyDGfRlTVVPWopHl5ktp XxHJXz5m4BMIfIxROIiBbXa3ufu4H05SFC6QrYoQAvsGmOfAPWnIRGJ0UHHdxsvvwTsi ToTApymVwQdc6Ghq0pD8XstmxiA5o0WJbX8Nf0pTysBP7y0raxQW/7xv3gxcBhC9StQQ cpFh3P/a8T4Dfl/GrqAVmwqd0WWkoFdboKa8zHfyzln0Dh9ij+aACdvBZTcQXYb4JlR8 Br4hTiIFnfHROc/qYaMuJfeG2IyoazzrvLsAvPFnG2mi7lUGGXe/4FwVTRd30XhUdYX2 YyVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jHOv7Zfc; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x26si8911145edv.178.2021.01.19.07.11.59; Tue, 19 Jan 2021 07:12:26 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=jHOv7Zfc; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387543AbhASPI5 (ORCPT + 99 others); Tue, 19 Jan 2021 10:08:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390097AbhASPHB (ORCPT ); Tue, 19 Jan 2021 10:07:01 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D2AC06179B for ; Tue, 19 Jan 2021 07:05:29 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id 23so29480753lfg.10 for ; Tue, 19 Jan 2021 07:05:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gOmgvCPsNvi85/TpBsHHlznh/AXeaDwbv8LGPCZK7GU=; b=jHOv7ZfcUJDyBrUH8oJXnGIi8zR/GVQigV9JsU3VOD2zVPzE8Qi8FcxCv3RN2B9A6r xugkjyegXRk25clhQPkHPl6Bgq5is0HjaMKTdere1dxwfXiSoujavM6bCqwMy7DZTLAY XzwyrYIOx+UbZ4taCEFKeVgvzFkPqWMiBrHN0cesc58X2THa+V2gdhqFGvQ0m5hl69PP 86p4cNSHXci62Q5bRCDCUjqJlCKurpnZ2KQ8/bUtutXFEHhOZcuBiBOGHUyG7S3P/OJ0 UhrskVG5YmmxTBCZMbabr3ZIzMkK81tYRiWGV1k3KMjBXOmM5Zrq6ssCUVgGucgyhjVM mc6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gOmgvCPsNvi85/TpBsHHlznh/AXeaDwbv8LGPCZK7GU=; b=Rm1EtgUylnZlpsjwyp/6y9sNpsvb699JdhRJF7A9NE86LIzR7ExpcFrTb7F1PkSRED dxCrpzojzpwUwGanQXPebCkdjtomU9BDzKWzBHSGQVcX6KoV7prxnJupM7vRgX2gUCSv wRjSJjzm5+cN+en9XL+M96jKgzcpD2iDaW1de7Tf7ydvFu9B/LKMC02RgtrQBf5iuiE+ K40fAjlUTE1VWgPa0os3SWrZinT9UMvI59ERmaQIUMIzigwyNrbXzm3oAKQHnswAO9JP XA5QEdRSKocMer8SLfvt2FHm/l8FENaqfp+4RaZgl0mEUbQUnXBrtcITm+zKXy4TFcg4 bWrQ== X-Gm-Message-State: AOAM533CL1/RCJz56V7buhqhyehUW9YmHNStWukckFLTPYLCV29gPRU5 AUQRhJg+yhUX+6X/ylLhhb9WZggQSALFU/FnfFllLg== X-Received: by 2002:a19:197:: with SMTP id 145mr2043470lfb.352.1611068727150; Tue, 19 Jan 2021 07:05:27 -0800 (PST) MIME-Version: 1.0 References: <20210112220124.837960-1-christian.brauner@ubuntu.com> <20210112220124.837960-16-christian.brauner@ubuntu.com> In-Reply-To: <20210112220124.837960-16-christian.brauner@ubuntu.com> From: Jann Horn Date: Tue, 19 Jan 2021 16:05:00 +0100 Message-ID: Subject: Re: [PATCH v5 15/42] fs: add file_user_ns() helper To: Christian Brauner 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?Q?St=C3=A9phane_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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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.