From: paeyz <iwasbaeyz@gmail.com>
To: Russell King <linux@armlinux.org.uk>, gregkh@linuxfoundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@kernel.org, Kees Cook <kees@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH v2] adfs: validate nzones in adfs_validate_bblk()
Date: Sat, 21 Mar 2026 00:52:13 +0900 [thread overview]
Message-ID: <20260320155213.2812-1-iwasbaeyz@gmail.com> (raw)
In-Reply-To: <2026032039-agility-ferocity-6ee0@gregkh>
From: Bae Yeonju <iwasbaeyz@gmail.com>
Reject ADFS disc records with a zero zone count during boot block
validation, before the disc record is used.
When nzones is 0, adfs_read_map() passes it to kmalloc_array(0, ...)
which returns ZERO_SIZE_PTR, and adfs_map_layout() then writes to
dm[-1], causing an out-of-bounds write before the allocated buffer.
adfs_validate_dr0() already rejects nzones != 1 for old-format
images. Add the equivalent check to adfs_validate_bblk() for
new-format images so that a crafted image with nzones == 0 is
rejected at probe time.
Found by syzkaller.
Fixes: f6f14a0d71b0 ("fs/adfs: map: move map-specific sb initialisation to map.c")
Tested-by: Bae Yeonju <iwasbaeyz@gmail.com>
Signed-off-by: Bae Yeonju <iwasbaeyz@gmail.com>
---
fs/adfs/super.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 4d3015e3a..b5522b862 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -343,6 +343,9 @@ static int adfs_validate_bblk(struct super_block *sb, struct buffer_head *bh,
if (adfs_checkdiscrecord(dr))
return -EILSEQ;
+ if ((dr->nzones | dr->nzones_high << 8) == 0)
+ return -EILSEQ;
+
*drp = dr;
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-03-20 15:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 14:23 [PATCH] adfs: validate nzones in adfs_read_map() Greg Kroah-Hartman
2026-03-20 14:37 ` Russell King (Oracle)
2026-03-20 15:05 ` Greg Kroah-Hartman
2026-03-20 15:21 ` paeyz
2026-03-20 15:40 ` Greg KH
2026-03-20 15:52 ` paeyz [this message]
2026-03-20 16:04 ` [PATCH v2] adfs: validate nzones in adfs_validate_bblk() Greg KH
2026-03-20 16:08 ` Russell King (Oracle)
2026-03-20 16:11 ` Greg KH
2026-03-21 4:45 ` [PATCH v3] " paeyz
2026-03-20 16:05 ` [PATCH] adfs: validate nzones in adfs_read_map() Russell King (Oracle)
2026-03-20 16:02 ` Russell King (Oracle)
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=20260320155213.2812-1-iwasbaeyz@gmail.com \
--to=iwasbaeyz@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=stable@kernel.org \
--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