public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leo Stone <leocstone@gmail.com>
To: syzbot+2db3c7526ba68f4ea776@syzkaller.appspotmail.com,
	brauner@kernel.org, quic_jjohnson@quicinc.com, jack@suse.cz,
	viro@zeniv.linux.org.uk, sandeen@redhat.com
Cc: Leo Stone <leocstone@gmail.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [hfs?] KMSAN: uninit-value in hfs_read_inode
Date: Fri, 22 Nov 2024 14:19:50 -0800	[thread overview]
Message-ID: <20241122221953.18329-1-leocstone@gmail.com> (raw)
In-Reply-To: <67400d16.050a0220.363a1b.0132.GAE@google.com>

After the call to hfs_bnode_read on line 356 of fs/hfs/super.c, the
struct hfs_cat_rec, which is supposed to be for the root dir, has
type HFS_CDR_FIL. Only the first 70 bytes of that struct are then
initialized, because the entrylength passed into hfs_bnode_read is
70, corresponding to the size of struct hfs_cat_dir. This causes
uninitialized values to be used later on when the hfs_cat_rec
union is treated as a hfs_cat_file.

Add a check to make sure the retrieved record has the correct type
for the root directory (HFS_CDR_DIR).

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

---
 fs/hfs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 3bee9b5dba5e..02d78992eefd 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -354,6 +354,8 @@ static int hfs_fill_super(struct super_block *sb, struct fs_context *fc)
 			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.43.0


  reply	other threads:[~2024-11-22 22:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-22  4:48 [syzbot] [hfs?] KMSAN: uninit-value in hfs_read_inode syzbot
2024-11-22 22:19 ` Leo Stone [this message]
2024-11-22 22:52   ` syzbot
2024-11-23 19:49 ` [PATCH] hfs: Sanity check the root record Leo Stone
2024-11-26  9:33   ` Jan Kara
2024-11-26 17:21     ` Leo Stone
2024-11-26 21:52       ` Jan Kara
2024-12-01  4:27         ` Leo Stone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241122221953.18329-1-leocstone@gmail.com \
    --to=leocstone@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_jjohnson@quicinc.com \
    --cc=sandeen@redhat.com \
    --cc=syzbot+2db3c7526ba68f4ea776@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox