Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2385839pxb; Sun, 15 Nov 2020 02:51:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJy781rM+x9BRz8kEOIPwKm/5olcdNXCTt2J9AypgbLvjhxhYCz3zWSNx9Hm/yQwEaLCq99a X-Received: by 2002:a50:b224:: with SMTP id o33mr10734126edd.21.1605437486525; Sun, 15 Nov 2020 02:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605437486; cv=none; d=google.com; s=arc-20160816; b=fkM0nY7+KnjULjKHkQVnSgl0Pqz9vocea06rrLsYrhDEqACSP/NEnrKdHaRmdlDPhC ED09Tpr5MvVKLrGuoumH4SsVeVM9C8uayPkaXImMBC22AJ4gZJcYVPLnH41CBU9Okufg XjNaxzwEagEM1t8WHMOoy2yw9eWMTDJQ90v3tPrf7CQ1QtdzC0B+zRLLqF84i/dYNIFT FlWyUnN0H0KiiWnBJH009nrduE1pbaTXDMj/eJskuElDLYhT3nLjZqbyt1UdWKo987LS KTAwLdSQW+OmDw6+pjGslhaufTY3u7HWmYk8oFqvyAG8pO7KIgvoMCtVKXZT6SBM3Kbd loEA== 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=DVk9fPtjRO/q6Rt0k6L6dd98vOpvbyCP8To/hei1EXs=; b=szMykTCbwq5elVK1Jkzl9t87AaH/DNUdmu/fuBxVVgTZ5Cv9FXWes7VD6LK52lepuG 36rP7iYpCN7og95QTi2evGlb5TQpuVjwdBJnoZSojT1SbuBeopiKSI+CmievY3V3wBiS ZYguLpbLcPGz4dTOmGvnt4xKK6tnEO80uRMk972XsaogJ4XmHPJ5YDWLReh5QED17NJr 6eb5GtZ58AayO948oGvZ6k6zhy3vqV+jplbhgdioG4zmWTc6wc22Wmh8gdNmayZR1dKq gHz+P2nDqP5wXJFWkjGMP5rsN+XgtGaPCVNZ6leYq8frxYPaHYAycoy5FLCduh/pItJZ EHBg== 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 p15si10308816edq.35.2020.11.15.02.51.03; Sun, 15 Nov 2020 02:51: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; 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 S1727080AbgKOKuZ (ORCPT + 99 others); Sun, 15 Nov 2020 05:50:25 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:60106 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726938AbgKOKuZ (ORCPT ); Sun, 15 Nov 2020 05:50:25 -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 1keFRy-0000Kt-8T; Sun, 15 Nov 2020 10:40:02 +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 35/39] ecryptfs: do not mount on top of idmapped mounts Date: Sun, 15 Nov 2020 11:37:14 +0100 Message-Id: <20201115103718.298186-36-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 Prevent ecryptfs from being mounted on top of idmapped mounts until we have ported it to handle this case and added proper testing for it. Cc: Christoph Hellwig Cc: David Howells Cc: Al Viro Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner --- /* v2 */ patch introduced --- fs/ecryptfs/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index e63259fdef28..c739f42157db 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c @@ -531,6 +531,12 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags goto out_free; } + if (mnt_idmapped(path.mnt)) { + rc = -EINVAL; + printk(KERN_ERR "Mounting on idmapped mounts currently disallowed\n"); + goto out_free; + } + if (check_ruid && !uid_eq(d_inode(path.dentry)->i_uid, current_uid())) { rc = -EPERM; printk(KERN_ERR "Mount of device (uid: %d) not owned by " -- 2.29.2