Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp31225pxb; Tue, 12 Jan 2021 19:05:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpHU7oy74+i4PEtcbXQJo6Adymhc+soZz734w0NcP9fqnH50C5jzcliilzalePhSp3U+X8 X-Received: by 2002:a05:6402:3192:: with SMTP id di18mr87459edb.332.1610507152641; Tue, 12 Jan 2021 19:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610507152; cv=none; d=google.com; s=arc-20160816; b=AAkJxdhe+pEIZkbIieJYgZB+8rNo3bWcYbbSxBRPt7CENrPqJm5/KpWrzVetQprYmX COqkExgM73sHB68LpcQVyavLYBIXAfWFbXW79pRxaMv0aHqOcOpC3zQ532DJV1HOyexE RjHKCwdKYktckdgFIJH5LlW4BfrJAbyYa5KI2OlXpqNYjiLkUHPv74OfJPKZJ3wOCGrH fVzfI74mmxCDTF7lIoBd1l+5fJcHdA1e5h0q00hEcll79bFo531vMtQkh5hWJqhECxuZ 0vfWK686hvxyd5le9Vx95t2yq66pjWVfvUcB3q3aR/9b/LYtjETpMpsHm6lMWtRjMmbW 3utA== 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=ua6i9kN1+Lw1me1u+QPLyRTDhkua3/s++0B/0K2aAo4=; b=Ks00rXR6pcgLtBIfl0k+1PrqOcWBiu6yjYL9qlMXooN6THoi6xAxaH9mNFAEbA0Aqa Ym9oRjbZTMe29V0GVwMqi2F+8r20u0EH7z5+wSdRWaJC2MHjM6qyptztK88cumvomoHN oXFYQcJWUgUb1nKBQYL9hKLIYayHMjNUvEMKGy4/e1OTx6YI93o03KQCNJEf56eP/aax EwOgvuVMCRFp7kQyDbpTKMCPwpZfUxOO59u7NvLRp2i54RIQ2AtaXPRSMyIm3BOaCQb4 4gaUAN6HPGE3BmUT2pSGlnbhrqR2y39Q92cBIZWq/144oMjAUjN1mS4tAE+dA+zhAPPg KXJg== 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 gs18si363175ejb.435.2021.01.12.19.05.29; Tue, 12 Jan 2021 19:05:52 -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 S2438009AbhALWPv (ORCPT + 99 others); Tue, 12 Jan 2021 17:15:51 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:44659 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436786AbhALWPE (ORCPT ); Tue, 12 Jan 2021 17:15:04 -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 1kzRlb-0003bd-4v; Tue, 12 Jan 2021 22:03:55 +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 26/42] fcntl: handle idmapped mounts Date: Tue, 12 Jan 2021 23:01:08 +0100 Message-Id: <20210112220124.837960-27-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=79BfejdDgH1ldNWwCcl2HPMsbZ+QshNiYeRA/Vyc6bM=; m=FGBRqZW9kX+0QUrItseootp4lAC2KvbC1yD/fw9Fke8=; p=r9rGnrNawGj5+EUFX+OMWIOsx3y9vDbV91x7CMyj/xU=; g=764e8b39eed7589416effdff14896d5d3ca522b9 X-Patch-Sig: m=pgp; i=christian.brauner@ubuntu.com; s=0x0x91C61BC06578DCA2; b=iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCX/4YtwAKCRCRxhvAZXjcou+KAQDjcqJ hPMsUm7m6JtnmHbfrJ0uCy40qs0JWJolzFqK4ygD8CvIC1MHT52bxtny+mmxr9VZ096EUZAHp/ZXY Tdpyvg0= Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Enable the setfl() helper 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/fcntl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index 74d99731fd43..58706031e603 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ static int setfl(int fd, struct file * filp, unsigned long arg) /* O_NOATIME can only be set by the owner or superuser */ if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) - if (!inode_owner_or_capable(&init_user_ns, inode)) + if (!inode_owner_or_capable(mnt_user_ns(filp->f_path.mnt), inode)) return -EPERM; /* required for strict SunOS emulation */ -- 2.30.0