From: Bae Yeonju Date: Sat, 21 Mar 2026 04:45:02 +0000 (+0900) Subject: fs/adfs: validate nzones in adfs_validate_bblk() X-Git-Tag: v7.1-rc1~8^2~2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=dd9d3e16c2d5fa166e13dce07413be51f42c8f5d;p=thirdparty%2Fkernel%2Flinux.git fs/adfs: validate nzones in adfs_validate_bblk() 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") Signed-off-by: Bae Yeonju Signed-off-by: Russell King (Oracle) --- diff --git a/fs/adfs/super.c b/fs/adfs/super.c index 2c5b2076acf9e..a4cd0a5159dd1 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c @@ -317,6 +317,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; }