Patch "erofs: fix file-backed mounts over FUSE" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    erofs: fix file-backed mounts over FUSE

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     erofs-fix-file-backed-mounts-over-fuse.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 97a9e952fac2018ff9a1dba6f3a7658133532b96
Author: Gao Xiang <xiang@xxxxxxxxxx>
Date:   Fri Nov 15 07:49:05 2024 +0800

    erofs: fix file-backed mounts over FUSE
    
    [ Upstream commit 3a23787ca8756920d65fda39f41353a4be1d1642 ]
    
    syzbot reported a null-ptr-deref in fuse_read_args_fill:
     fuse_read_folio+0xb0/0x100 fs/fuse/file.c:905
     filemap_read_folio+0xc6/0x2a0 mm/filemap.c:2367
     do_read_cache_folio+0x263/0x5c0 mm/filemap.c:3825
     read_mapping_folio include/linux/pagemap.h:1011 [inline]
     erofs_bread+0x34d/0x7e0 fs/erofs/data.c:41
     erofs_read_superblock fs/erofs/super.c:281 [inline]
     erofs_fc_fill_super+0x2b9/0x2500 fs/erofs/super.c:625
    
    Unlike most filesystems, some network filesystems and FUSE need
    unavoidable valid `file` pointers for their read I/Os [1].
    Anyway, those use cases need to be supported too.
    
    [1] https://docs.kernel.org/filesystems/vfs.html
    
    Reported-by: syzbot+0b1279812c46e48bb0c1@xxxxxxxxxxxxxxxxxxxxxxxxx
    Closes: https://lore.kernel.org/r/6727bbdf.050a0220.3c8d68.0a7e.GAE@xxxxxxxxxx
    Fixes: fb176750266a ("erofs: add file-backed mount support")
    Tested-by: syzbot+0b1279812c46e48bb0c1@xxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20241114234905.1873723-1-hsiangkao@xxxxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 61debd799cf90..fa51437e1d99d 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -38,7 +38,7 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
 	}
 	if (!folio || !folio_contains(folio, index)) {
 		erofs_put_metabuf(buf);
-		folio = read_mapping_folio(buf->mapping, index, NULL);
+		folio = read_mapping_folio(buf->mapping, index, buf->file);
 		if (IS_ERR(folio))
 			return folio;
 	}
@@ -61,9 +61,11 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb)
 {
 	struct erofs_sb_info *sbi = EROFS_SB(sb);
 
-	if (erofs_is_fileio_mode(sbi))
-		buf->mapping = file_inode(sbi->fdev)->i_mapping;
-	else if (erofs_is_fscache_mode(sb))
+	buf->file = NULL;
+	if (erofs_is_fileio_mode(sbi)) {
+		buf->file = sbi->fdev;		/* some fs like FUSE needs it */
+		buf->mapping = buf->file->f_mapping;
+	} else if (erofs_is_fscache_mode(sb))
 		buf->mapping = sbi->s_fscache->inode->i_mapping;
 	else
 		buf->mapping = sb->s_bdev->bd_mapping;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 4efd578d7c627..9b03c8f323a76 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -221,6 +221,7 @@ enum erofs_kmap_type {
 
 struct erofs_buf {
 	struct address_space *mapping;
+	struct file *file;
 	struct page *page;
 	void *base;
 	enum erofs_kmap_type kmap_type;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux