Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp32926pxb; Tue, 12 Jan 2021 19:08:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyguN7DgP8Blnz8ncGVoR778gp3Bya4UV5Sdad4v7+seAdNDsu7tiaQFHJevZupSlpsCrAt X-Received: by 2002:a17:906:4348:: with SMTP id z8mr4051ejm.371.1610507318587; Tue, 12 Jan 2021 19:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610507318; cv=none; d=google.com; s=arc-20160816; b=AXFcO+kGuEjo3mYC40El3FYPxNrFGAZLGA+5/PX+rT4rbrMk7I/gFF48Ve4a0UWr1f g8hicLz3SxVGqclHFZACPB5jzKjrmYcgAiaz3TnV3JZrPlkU06puKqiJLwap02p8xHDM fknIKeaCae1tkwz2aOeFmkqTG/6pxDwb04Bd8xj46CkFIMs2ewdhCWZZws16KQEM7wyL fwNO8JI8gL/yZo1sBA4N1DP082PM+lcYvejtJ/Rv7Ht64zSBdN2PrE8FnI93Y6fe+l9t x5pknaRd5G0PR3UztBVVhiLhXW66gbc6dL8L61xuTwan9rR6tcjoS7vH0dhpdYIzzoHS 3lnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2pJlHI+9y6rPxOuAhsr+wlrnq5GGaPYcBpJZvWFKREk=; b=FK4uQm/ylP2yZ+UNKwQmqVGKDh3vA90o/mCpt5McqFpIZHX4T2Yy/bAZQgz09KfrRA DcCTh6B/yWwzwfHgp7d3GjdICEQbOcVyyCIW2WPaJLYG1L2ZTNamtYxNNkrjyuMkT2SD 5YUuU3PACjm6Ej/aCBKy7SB2twMT0zXnjhelyIiC+SiRgQ5T9uXOQDHncVjrQcQCUrAx zc+zrY7YTtYdFD3nYcM7x7C+Pojf6GY0KhiYibP6RbetMTF88nrlMDdtJZP7Fsmz4H3C Zi7fn1/QSRIU9PK0BHpY5hZZ0hl0n9qWbUckn5/YxBPxNpti+BOjyR/jteZwSdgrve7D Sp3w== 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 u10si374774edd.90.2021.01.12.19.08.15; Tue, 12 Jan 2021 19:08:38 -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 S2405362AbhALWRr (ORCPT + 99 others); Tue, 12 Jan 2021 17:17:47 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:45133 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438270AbhALWRo (ORCPT ); Tue, 12 Jan 2021 17:17:44 -0500 Received: from ip5f5af0a0.dynamic.kabel-deutschland.de ([95.90.240.160] helo=wittgenstein.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kzRld-0003bd-DP; Tue, 12 Jan 2021 22:03:57 +0000 From: Christian Brauner To: Alexander Viro , Christoph Hellwig , linux-fsdevel@vger.kernel.org Cc: 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=20Graber?= , Linus Torvalds , Aleksa Sarai , Lennart Poettering , "Eric W. Biederman" , smbarber@chromium.org, Phil Estes , Serge Hallyn , Kees Cook , Todd Kjos , Paul Moore , Jonathan Corbet , containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, Christian Brauner , Christoph Hellwig Subject: [PATCH v5 27/42] notify: handle idmapped mounts Date: Tue, 12 Jan 2021 23:01:09 +0100 Message-Id: <20210112220124.837960-28-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210112220124.837960-1-christian.brauner@ubuntu.com> References: <20210112220124.837960-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=m4dSb1vZZyg/6OFc1HkrzZoINWVfXi6fEBCLScH9qO8=; m=L41rIL7rk4mTNxft12WYGnDO5UtEpl+ZRCRY1mXiFD4=; p=llIL77s1jziMeTXIOvn4NXU9WjoPCcFX94fV2iuBuAE=; g=251f87afe6b169e0d3ecada7420b76fa9931ce4f X-Patch-Sig: m=pgp; i=christian.brauner@ubuntu.com; s=0x0x91C61BC06578DCA2; b=iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCX/4YtwAKCRCRxhvAZXjcorEWAQC71l+ QLOLv+C2pRpl8uUNOVG8zRFchwfy6QElf2fHIyQEA4ZumE87DNQH0HrIO30nTP/w8RRjNy/LP24gV QqajeQg= Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Enable notify implementations to handle idmapped mounts by passing down the mount's user namespace. If the initial user namespace is passed nothing changes so non-idmapped mounts will see identical behavior as before. Cc: Christoph Hellwig Cc: David Howells Cc: Al Viro Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner --- /* v2 */ patch introduced /* v3 */ unchanged /* v4 */ unchanged /* v5 */ base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837 --- fs/notify/fanotify/fanotify_user.c | 2 +- fs/notify/inotify/inotify_user.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 4ca13fb33c7c..c60b8cc1f94d 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -702,7 +702,7 @@ static int fanotify_find_path(int dfd, const char __user *filename, } /* you can only watch an inode if you have read permissions on it */ - ret = inode_permission(&init_user_ns, path->dentry->d_inode, MAY_READ); + ret = inode_permission(mnt_user_ns(path->mnt), path->dentry->d_inode, MAY_READ); if (ret) { path_put(path); goto out; diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 18e7024207a9..cecff22549d7 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "inotify.h" #include "../fdinfo.h" @@ -352,7 +353,7 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, if (error) return error; /* you can only watch an inode if you have read permissions on it */ - error = inode_permission(&init_user_ns, path->dentry->d_inode, MAY_READ); + error = inode_permission(mnt_user_ns(path->mnt), path->dentry->d_inode, MAY_READ); if (error) { path_put(path); return error; -- 2.30.0