From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56AEF606A31C for ; Mon, 16 Nov 2026 12:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jHefcERQ; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U7641dzb DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=YaBmWD0H2e/byZAd7Xmvk9z8GUGshWVsh+H9VIaIL8k=; b=jHefcERQqUmXC+ UCDXctGh3+Oy1uNP/mzy1zroRhpCIgvW5sQ5DVhJDNYaD/GUvf/F4OT+A12UUim+HbcuqOncoizxr Cl0FR6OnwvsBR4v4qUop2KYiG+gVY+MDe/uYE0rOocb4sMK7rH08vucTKC74YCY1b25j3BVJA4JBi Y9zSoopbmTRyD7puvWTxdeC5qeOhwtfQBGQ2+3ZC8Hg9gR8FN7wN3D05+G9CFRAnWRpuTyEFX+g86 fQLAHSi9bNkjlGzMhNf1MvwiqQYiWtUjW2ynYL0yxZDQT95jexpmdjxcDCvSRL8d/17yN9y9EsSLB PfYovMjjauu9olRHx0ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xSvzz-00000002P6y-3L14; Mon, 16 Nov 2026 12:39:51 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xSucG-0000000280E-2yWU for linux-nvme@lists.infradead.org; Mon, 16 Nov 2026 11:11:16 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 53E4842DAA; Mon, 16 Nov 2026 11:11:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CD541F000CC; Mon, 16 Nov 2026 11:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794827476; bh=YaBmWD0H2e/byZAd7Xmvk9z8GUGshWVsh+H9VIaIL8k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=U7641dzbHi68FgoVcp+Qc4aB66pQAxq0SE1VggFUvf3UptU6PSOSPxEuUVckdRFis gBdbXWAgknUxf2WOR6QRrK3mJ7qo4sKt2MVBW1KDfKbm9AEAp5P0WwCNwKFdlGvNSy V+LVCf2Qz9d+7FNEGVOUuPu12FvHNYURFOX6j7vwsicSvTt2onQWRzpOR7NkfIWHRv 54vr7WI+NATWXTFWM2Ht/34FIxDP08XFbN+qBvortmw0+AQaDGektha4t5P60B/Z7W Rlh6fXap3z/icrBIH9mQxI7rbDe6cWHLoTt0lp7fefcljhZ916IZ4wrFIl7C8tMdpx jCqLwaSdQUg0Q== From: Christian Brauner Date: Mon, 16 Nov 2026 12:05:15 +0100 Subject: [PATCH RFC v3 42/44] erofs: refuse files on pseudo filesystems as backing files X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261116-work-loop-pseudo-v3-42-8cbbea1cf34f@kernel.org> References: <20261116-work-loop-pseudo-v3-0-8cbbea1cf34f@kernel.org> In-Reply-To: <20261116-work-loop-pseudo-v3-0-8cbbea1cf34f@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jann Horn , Chris Mason , Josef Bacik , Christoph Hellwig , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Alexander Viro , Jan Kara , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, driver-core@lists.linux.dev, linux-mm@kvack.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, apparmor@lists.ubuntu.com, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, fuse-devel@lists.linux.dev, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org, ocfs2-devel@lists.linux.dev, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-usb@vger.kernel.org, Amir Goldstein , linux-erofs@lists.ozlabs.org, linux-kselftest@vger.kernel.org, "Christian Brauner (Amutable)" , Gao Xiang , Alexander Mikhalitsyn , Chris Down X-Mailer: b4 0.17-dev-ce4c1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1701; i=brauner@kernel.org; h=from:subject:message-id; bh=zgPAmU25yXmDAhDS6CiCz+zo4qFZ1Bc8aFsU5Ev1fq4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWT9etw/L55Nunlnx5t7vJ/X/+JYMbt61QHto2pZr1jCR HcvcfmU2lHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjARwyhGhgu3NIKv371gIt3e 8vqomtbEY4GBy5Y4t/xe8OHknsJosW2MDH/6VfjO+i712/2j3JGf97jpsQb1eOXvkkXpJpPWOPU 9YAEA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Mailman-Approved-At: Mon, 16 Nov 2026 04:39:20 -0800 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 File-backed mounts take any regular file as the image and the same goes for the extra devices of such a mount. erofs reads them with the credentials of the mounter so this doesn't hand out anything the mounter couldn't read anyway. But files on pseudo filesystems aren't images. Refuse them just like loop does. file_check_backing() also checks that the file is open for reading. So a source file descriptor that erofs can't read from fails the mount right away instead of on the first read. Reviewed-by: Gao Xiang Reviewed-by: Alexander Mikhalitsyn Reviewed-by: Chris Down Signed-off-by: Christian Brauner (Amutable) --- fs/erofs/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index ce05557bd9983..517a289b9395c 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -158,7 +158,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb, if (!erofs_is_fileio_mode(sbi)) { dif->dax_dev = fs_dax_get_by_bdev(file_bdev(file), &dif->dax_part_off, NULL, NULL); - } else if (!S_ISREG(file_inode(file)->i_mode)) { + } else if (file_check_backing(file, FMODE_READ, 0)) { fput(file); return -EINVAL; } @@ -835,6 +835,9 @@ static int erofs_file_get_tree(struct fs_context *fc) { struct erofs_sb_info *sbi = fc->s_fs_info; + if (file_check_backing(sbi->dif0.file, FMODE_READ, 0)) + return invalfc(fc, "source can't be used as a backing file"); + if (!test_opt(&sbi->opt, SUPERBLOCK_SHARE)) return get_tree_nodev(fc, erofs_fc_fill_super); -- 2.53.0