[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH RFC v2 33/42] fs: add file_check_backing()
- To: Chris Down <chris@xxxxxxxxxxxxxx>
- From: Amir Goldstein <amir73il@xxxxxxxxx>
- Date: Sun, 15 Nov 2026 00:19:57 +0100
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=98mXXJR5XCg4Z4S2yqrizowpYg4fQiN0pgPOU/BiUFY=; fh=PnMlckc2mHwAKI6QRQw4d75G+adqSQZCq9Rb7q2rces=; b=Vo5k7EIDnVKCmGXdUlfJa8+WgiaAHQpwuBo3BdpqKByiTBBjN8psITbnDR6iVRSBMl yWzlKBlV+4YuztcDV/f7WK9/0GcuflBYSd6u+/zZYAJKmFOd9TI47FiwuOT1Jq8H7qiu eQ/uurNGFwPTyDl5eVvk+ZS2hlX6dQqTW3aDI9GJgusfU4UIAosWgreUNpVuzaYGrB+A RpGjzcUuZy59R4Re3lQXZkpapzn00eCydx+lMcmPaLZSYn0hZbPan8rq2zHa22Xsoc+S Ffb1PyPxhowIy4wzJW/mBAWzroy9D3GnFT90JxCgVhCdtSmiej/+GqbpFdGpkhhMcrSU nHAQ==; darn=lists.xenproject.org
- Arc-seal: i=1; a=rsa-sha256; t=1794698409; cv=none; d=google.com; s=arc-20260327; b=iSNMHchSMpPnYiZQ8Mn5XxXES6Pc/dFADNNIOEGhZ51x7v8tc+Iofv9Cmw6EQ7R74d xxJ91+StPnMFhmq1rVw20kwMpfXu7Bsv9wr5gOxqp55OsNNnSXlQdfeqOMWcr9MlLWWk 5uO9mHVyEFjb02iAc8a8VJOtu7wR3P2nL+wW8g+I6wal+2ifyk3pZxX8h1pmi745JaEd Yk0jl2v45Fc40Tm0BQEO45ytZrJ2NpPisSYH4BH8V22FSV2i7vm/WkZbnp7ju/GuAFPs kuVMPnSG4xNu3TsbB94kOC6dPUjTzVUlwaz23mKtUxnG1unRfF/LGDw77CejjjsU1lrA hgOw==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
- Cc: Christian Brauner <brauner@xxxxxxxxxx>, linux-fsdevel@xxxxxxxxxxxxxxx, Jann Horn <jannh@xxxxxxxxxx>, Chris Mason <mason@xxxxxxxxxx>, Josef Bacik <josef@xxxxxxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, linux-block@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-nvme@xxxxxxxxxxxxxxxxxxx, Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>, Jan Kara <jack@xxxxxxx>, linux-scsi@xxxxxxxxxxxxxxx, target-devel@xxxxxxxxxxxxxxx, driver-core@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, bpf@xxxxxxxxxxxxxxx, linux-security-module@xxxxxxxxxxxxxxx, selinux@xxxxxxxxxxxxxxx, apparmor@xxxxxxxxxxxxxxxx, linux-nfs@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, fuse-devel@xxxxxxxxxxxxxxx, linux-efi@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, ocfs2-devel@xxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-usb@xxxxxxxxxxxxxxx, linux-erofs@xxxxxxxxxxxxxxxx, linux-kselftest@xxxxxxxxxxxxxxx
- Delivery-date: Sat, 14 Nov 2026 23:20:24 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Sat, Nov 14, 2026 at 9:06 PM Chris Down <chris@xxxxxxxxxxxxxx> wrote:
>
> Hi Christian,
>
> Christian Brauner writes:
> >+ /* Look through stacking filesystems at the inode with the data. */
> >+ if (d_real_inode(file->f_path.dentry)->i_sb->s_iflags & SB_I_PSEUDO)
> >+ return -EINVAL;
>
> This looks good in general, but what the bots said about O_PATH files
> here is real. With FMODE_PATH this is reached for a file that was never
> opened, so on overlayfs nothing has been through ovl_open() to look up
> the lowerdata of a metacopy file yet. ovl_d_real() then does the lookup
> itself, and when that fails it hits the WARN(1) at its end and returns
> the overlayfs dentry, so the check passes as well.
>
> Only fuse passes FMODE_PATH, so it takes CAP_SYS_ADMIN to get there, but
> it's easy to trigger with that. From a quick test with a metacopy file
> whose redirect into a data-only layer points at nothing, registering an
> O_PATH fd of it with FUSE_DEV_IOC_BACKING_OPEN gives
>
> ovl_d_real(/f, 0): real dentry not found
> WARNING: fs/overlayfs/super.c:79 at ovl_d_real+0xc9/0x210
> [...]
> file_check_backing+0x308/0x5e0
> fuse_backing_new+0x219/0x4a0
> fuse_backing_open+0xe8/0x390
> fuse_dev_ioctl+0x53a/0x7d0
>
> and the ioctl still succeeds. A normal open of that file fails with
> ENOENT, so nothing could have used it as a backing file anyway, but with
> panic_on_warn this is now a panic.
>
> Maybe ovl_d_real() should just stop warning when the lookup fails, now
> that it has a caller that isn't trace_uprobe?
Yeh I guess that this needs to be a Fixes for lazy data lookup.
The correct fix would be to teach all the callers to deal with an error.
> The check would still pass
> for an O_PATH file whose lowerdata couldn't be looked up at that point,
> though.
One observation relevant to this patch set is that a datadir layer has no
business being a pseudo fs and that can and should be blocked explicitly
at overlayfs mount time.
The other observation is that fuse_passthrough_open() should probably
check the backing_file that was opened for io in addition to checking
in fuse_backing_open(), which could have different FMODE and specifically
could be FMODE_PATH.
Thanks,
Amir.
|