* [PATCH AUTOSEL 6.1 02/10] hfs: Sanity check the root record
[not found] <20250113183537.1784136-1-sashal@kernel.org>
@ 2025-01-13 18:35 ` Sasha Levin
2025-01-13 18:35 ` [PATCH AUTOSEL 6.1 03/10] fs: fix missing declaration of init_files Sasha Levin
2025-01-13 18:35 ` [PATCH AUTOSEL 6.1 09/10] iomap: avoid avoid truncating 64-bit offset to 32 bits Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-01-13 18:35 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Leo Stone, syzbot+2db3c7526ba68f4ea776, Jan Kara,
Christian Brauner, Sasha Levin, sandeen, viro, quic_jjohnson,
linux-fsdevel
From: Leo Stone <leocstone@gmail.com>
[ Upstream commit b905bafdea21a75d75a96855edd9e0b6051eee30 ]
In the syzbot reproducer, the hfs_cat_rec for the root dir has type
HFS_CDR_FIL after being read with hfs_bnode_read() in hfs_super_fill().
This indicates it should be used as an hfs_cat_file, which is 102 bytes.
Only the first 70 bytes of that struct are initialized, however,
because the entrylength passed into hfs_bnode_read() is still the length of
a directory record. This causes uninitialized values to be used later on,
when the hfs_cat_rec union is treated as the larger hfs_cat_file struct.
Add a check to make sure the retrieved record has the correct type
for the root directory (HFS_CDR_DIR), and make sure we load the correct
number of bytes for a directory record.
Reported-by: syzbot+2db3c7526ba68f4ea776@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2db3c7526ba68f4ea776
Tested-by: syzbot+2db3c7526ba68f4ea776@syzkaller.appspotmail.com
Tested-by: Leo Stone <leocstone@gmail.com>
Signed-off-by: Leo Stone <leocstone@gmail.com>
Link: https://lore.kernel.org/r/20241201051420.77858-1-leocstone@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/hfs/super.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 6764afa98a6f..431bdc65f723 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -418,11 +418,13 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
goto bail_no_root;
res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd);
if (!res) {
- if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
+ if (fd.entrylength != sizeof(rec.dir)) {
res = -EIO;
goto bail_hfs_find;
}
hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength);
+ if (rec.type != HFS_CDR_DIR)
+ res = -EIO;
}
if (res)
goto bail_hfs_find;
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH AUTOSEL 6.1 09/10] iomap: avoid avoid truncating 64-bit offset to 32 bits
[not found] <20250113183537.1784136-1-sashal@kernel.org>
2025-01-13 18:35 ` [PATCH AUTOSEL 6.1 02/10] hfs: Sanity check the root record Sasha Levin
2025-01-13 18:35 ` [PATCH AUTOSEL 6.1 03/10] fs: fix missing declaration of init_files Sasha Levin
@ 2025-01-13 18:35 ` Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-01-13 18:35 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Marco Nelissen, Darrick J . Wong, Christoph Hellwig,
Christian Brauner, Sasha Levin, linux-xfs, linux-fsdevel
From: Marco Nelissen <marco.nelissen@gmail.com>
[ Upstream commit c13094b894de289514d84b8db56d1f2931a0bade ]
on 32-bit kernels, iomap_write_delalloc_scan() was inadvertently using a
32-bit position due to folio_next_index() returning an unsigned long.
This could lead to an infinite loop when writing to an xfs filesystem.
Signed-off-by: Marco Nelissen <marco.nelissen@gmail.com>
Link: https://lore.kernel.org/r/20250109041253.2494374-1-marco.nelissen@gmail.com
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/iomap/buffered-io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 47f44b02c17d..70e246f7e8fe 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -907,7 +907,7 @@ static int iomap_write_delalloc_scan(struct inode *inode,
}
/* move offset to start of next folio in range */
- start_byte = folio_next_index(folio) << PAGE_SHIFT;
+ start_byte = folio_pos(folio) + folio_size(folio);
folio_unlock(folio);
folio_put(folio);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread