Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2385364pxb; Sun, 15 Nov 2020 02:49:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaA2BTPXGJgPbAPcbqBAzvT7GisrTQAWmo4u23YUjF6nW87JR0b0I3tftIltLML7M1RTsF X-Received: by 2002:a50:9f2b:: with SMTP id b40mr10844139edf.20.1605437399107; Sun, 15 Nov 2020 02:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605437399; cv=none; d=google.com; s=arc-20160816; b=ugy4u0sKcHbi0gdpLQbbhBt2qgcgG8qo9e4ZGI4VbGqMiad3eornAXiEC6TSBiAtUV HoNsYzDD3h5yHimJGgdAJiBToF85gJX5oAGEUlQxGkF2avSLTC/9ZYDxz3DnsGu+nUXs gdZIbw0IDOf5DvIN1lyGEC3GETqun9wT65WpCaKWemafJxP69VHALbSlQdUJ72n8oj7k PmYRqqYHaWwTI8ezdLaois/BH7ZT7U93PhpUwWtN49O1sCHqVCRl3Ny4e8lxG0UjgDTc ZXMInAWn3pkryrFbUWyF2A8nAhHg9pigmTzOKld/hxFk509BNztGASzln9O4m7TQxBXX Rtkw== 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=scgrDWSFj5A4UEkoioIozS/FL2cHfYEH7DPTAAkMpZ4=; b=jkGrd2Z4p8Jb+nMe8oodJrRMCsR6mcdTHItwR8PF5+c9DYGuI+M2j7AwTYZ9u9qLqh 2Ag5MHSrxQImzQY59AMm/Fiim4amVRkWWVGMA6s5t9XVTM1bJ8hEnWHlz/csyV/pvg5n MM2LKeHx8jWbI33tgfUp+c0uUH+/aY7YUuPZ1EjGIpNecD9zF/7KAB826Suw97E/cb2D 3AsUyH+B9g+zXHwekoajpn3rtmbH6w1hrqf1xHnvxOufuCejNz/ibJ6o8DK3t1PmH0Wq KYPV+LJDO/Y1KQFBfstME6IdnA0T6Cd9DtrlpPNdFqEOYnP7F+4xghIy4KYJ6EDGMAQ8 kBGw== 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 zc3si9476810ejb.158.2020.11.15.02.49.35; Sun, 15 Nov 2020 02:49:59 -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 S1727003AbgKOKtJ (ORCPT + 99 others); Sun, 15 Nov 2020 05:49:09 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:59947 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726749AbgKOKtJ (ORCPT ); Sun, 15 Nov 2020 05:49:09 -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 1keFRM-0000Kt-3D; Sun, 15 Nov 2020 10:39:24 +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 23/39] fcntl: handle idmapped mounts Date: Sun, 15 Nov 2020 11:37:02 +0100 Message-Id: <20201115103718.298186-24-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 the setfl() helper 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/fcntl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index df091d435603..ed330fa91438 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.29.2