Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2384825pxb; Sun, 15 Nov 2020 02:48:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJybE+frX+7BHYo38Vq1opijeExtSuqWFmYtwP5xeJZp6ODlsk+qiYB9XDvfXSJcneFpuKVo X-Received: by 2002:a05:6402:21c7:: with SMTP id bi7mr11139108edb.54.1605437302490; Sun, 15 Nov 2020 02:48:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605437302; cv=none; d=google.com; s=arc-20160816; b=bW2A5R/QIBeQ/t+xVU+f1+foWYzwkxsn984etQfFcqXwpozw6dWf9kLY4gk0AED4c+ XOuM9kUxD3GR4Qc43wzcG8UKiWlmS13hdwIwAHfVLa2AVq4RXUft8mLS6V+DDRqSsRYN N/M3+RnLLAMvcoQhFXBqLUQhlMrQijAXGVhLmvxCL3cOAP5bp2XVea808Qq8VrI4IG3q xYTZk5R8IhMJyvTkILO+BSiusQdbqed+b8yzJCGrRj5Xe5v4fpF+x+t9wqASxGoI6YyH +33svbnBOy1QraH+N0H8mYhdTo5eBk5d3YS6ZYX/AH0+KXSZnTCY6zEh6M5E6Ukqgy55 uewQ== 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=NuYjaWdlVIUS9/cMhD5HjJjywiedPWyTBY+B5b8PL8g=; b=L6n2M5zGeP+qxRs1beptoarZOT8soYSzojNdPrYQlEvIjUkamado50IJVfzkO6Nda1 JRZFdsonMH3hgZ1fzUcIgLi37dbCTOAzFvLyEtle2pjY8MzKealTxJDxXd3r1NBBOInj JEkzVys4nl1M2nqfDHwLZSwTIDnGbC0U4nU5E5KPGf2DuSNyMop+ws/vrku6YmV2z4IY JG6Qaj4xgFQb/7tHU6J+O0KWmQ87ht4pohd8cMIAxt3b/zFTVoa/s6b01SCbxciyMcTb 5+xT8LFlLirpwrASXPYIEsbFfJU0VnoX7fVOQD+kzfLNPWY4VjnICnxL1cfbE/oKA/PU B2Cw== 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 mm25si9162759ejb.610.2020.11.15.02.47.59; Sun, 15 Nov 2020 02:48:22 -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 S1726992AbgKOKpk (ORCPT + 99 others); Sun, 15 Nov 2020 05:45:40 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:59607 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbgKOKpk (ORCPT ); Sun, 15 Nov 2020 05:45:40 -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 1keFRP-0000Kt-DS; Sun, 15 Nov 2020 10:39:27 +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 , Jann Horn , Seth Forshee , =?UTF-8?q?St=C3=A9phane=20Graber?= , Aleksa Sarai , Lennart Poettering , "Eric W. Biederman" , smbarber@chromium.org, Phil Estes , Serge Hallyn , Kees Cook , Todd Kjos , Jonathan Corbet , containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-audit@redhat.com, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, Christian Brauner , Christoph Hellwig Subject: [PATCH v2 24/39] notify: handle idmapped mounts Date: Sun, 15 Nov 2020 11:37:03 +0100 Message-Id: <20201115103718.298186-25-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201115103718.298186-1-christian.brauner@ubuntu.com> References: <20201115103718.298186-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 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. Cc: Christoph Hellwig Cc: David Howells Cc: Al Viro Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner --- /* v2 */ patch introduced --- 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 de4d01bb1d8d..e3b2cb6a9d81 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 e995fd4e4e53..f39f5b81f2b3 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" @@ -343,7 +344,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.29.2