* [PATCH] hfsplus: fix uninit-value in hfsplus_cat_build_record
@ 2025-11-20 17:17 ssrane_b23
2025-11-20 17:34 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: ssrane_b23 @ 2025-11-20 17:17 UTC (permalink / raw)
To: slava, glaubitz, frank.li, linux-fsdevel, linux-kernel
Cc: skhan, linux-kernel-mentees, david.hunter.linux, khalid,
Shaurya Rane, syzbot+905d785c4923bea2c1db
From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
The root cause is in hfsplus_cat_build_record(), which builds catalog
entries using the union hfsplus_cat_entry. This union contains three
members with significantly different sizes:
struct hfsplus_cat_folder folder; (88 bytes)
struct hfsplus_cat_file file; (248 bytes)
struct hfsplus_cat_thread thread; (520 bytes)
The function was only zeroing the specific member being used (folder or
file), not the entire union. This left significant uninitialized data:
For folders: 520 - 88 = 432 bytes uninitialized
For files: 520 - 248 = 272 bytes uninitialized
This uninitialized data was then written to disk via hfs_brec_insert(),
read back through the loop device, and eventually copied to userspace
via filemap_read(), resulting in a leak of kernel stack memory.
Fix this by zeroing the entire union before initializing the specific
member. This ensures no uninitialized bytes remain.
Reported-by: syzbot+905d785c4923bea2c1db@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=905d785c4923bea2c1db
Fixes: 1da177e4c3f4
Signed-off-by: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
---
fs/hfsplus/catalog.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index 02c1eee4a4b8..4d42e7139f3b 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -111,7 +111,8 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry,
struct hfsplus_cat_folder *folder;
folder = &entry->folder;
- memset(folder, 0, sizeof(*folder));
+ /* Zero the entire union to avoid leaking uninitialized data */
+ memset(entry, 0, sizeof(*entry));
folder->type = cpu_to_be16(HFSPLUS_FOLDER);
if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags))
folder->flags |= cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT);
@@ -130,7 +131,8 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry,
struct hfsplus_cat_file *file;
file = &entry->file;
- memset(file, 0, sizeof(*file));
+ /* Zero the entire union to avoid leaking uninitialized data */
+ memset(entry, 0, sizeof(*entry));
file->type = cpu_to_be16(HFSPLUS_FILE);
file->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS);
file->id = cpu_to_be32(cnid);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hfsplus: fix uninit-value in hfsplus_cat_build_record
2025-11-20 17:17 [PATCH] hfsplus: fix uninit-value in hfsplus_cat_build_record ssrane_b23
@ 2025-11-20 17:34 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2025-11-20 17:34 UTC (permalink / raw)
To: ssrane_b23
Cc: slava, glaubitz, frank.li, linux-fsdevel, linux-kernel, skhan,
linux-kernel-mentees, david.hunter.linux, khalid,
syzbot+905d785c4923bea2c1db
On Thu, Nov 20, 2025 at 10:47:40PM +0530, ssrane_b23@ee.vjti.ac.in wrote:
> Reported-by: syzbot+905d785c4923bea2c1db@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=905d785c4923bea2c1db
> Fixes: 1da177e4c3f4
>
> Signed-off-by: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
This is not the correct format for the Fixes: tag. Here's the easy way
to do it: add this to your ~/.gitconfig
[pretty]
fixes=Fixes: %h ("%s")
Now you can type 'git show --pretty=fixes 1da177e4c3f4 |head -1 and it
will give you:
Fixes: 1da177e4c3f4 (Linux-2.6.12-rc2)
Also, don't put a blank line before your S-o-b line.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-20 17:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 17:17 [PATCH] hfsplus: fix uninit-value in hfsplus_cat_build_record ssrane_b23
2025-11-20 17:34 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).