]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
fs/adfs: validate nzones in adfs_validate_bblk()
authorBae Yeonju <iwasbaeyz@gmail.com>
Sat, 21 Mar 2026 04:45:02 +0000 (13:45 +0900)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thu, 9 Apr 2026 10:51:31 +0000 (11:51 +0100)
commitdd9d3e16c2d5fa166e13dce07413be51f42c8f5d
tree600d0730108433c5a2c50aa58b37dc9f907cc8b6
parent6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
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 <iwasbaeyz@gmail.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
fs/adfs/super.c