public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bae Yeonju <iwasbaeyz@gmail.com>, stable <stable@kernel.org>,
	Kees Cook <kees@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] adfs: validate nzones in adfs_read_map()
Date: Fri, 20 Mar 2026 16:05:03 +0100	[thread overview]
Message-ID: <2026032021-renewable-control-9c81@gregkh> (raw)
In-Reply-To: <ab1bmzFTIGB2o-zO@shell.armlinux.org.uk>

On Fri, Mar 20, 2026 at 02:37:15PM +0000, Russell King (Oracle) wrote:
> On Fri, Mar 20, 2026 at 03:23:56PM +0100, Greg Kroah-Hartman wrote:
> > From: Bae Yeonju <iwasbaeyz@gmail.com>
> > 
> > adfs_read_map() reads the zone count from the on-disk disc record
> > without validation:
> > 
> >   nzones = dr->nzones | dr->nzones_high << 8;
> > 
> > When nzones is 0, the subsequent kmalloc_array(0, ...) returns
> > ZERO_SIZE_PTR (0x10), and adfs_map_layout() writes to dm[-1],
> > causing an out-of-bounds write before the allocated buffer.
> > 
> > This can be triggered by mounting a crafted ADFS filesystem image
> > with nzones set to 0 in the disc record. It leads to kernel heap
> > corruption and a NULL pointer dereference during mount.
> > 
> > Add a check to reject disc records with nzones == 0 before the
> > allocation.
> > 
> > Found by syzkaller.
> 
> I didn't see this patch.

This is the first time it has been sent in public.

> This is a silly place to put the check - it should be done while
> validating the disc record, in adfs_validate_bblk(), not when trying
> to use it.
> 
> Note that adfs_validate_dr0() already validates the number of zones.

But then why is this check also needed?  I'm all for moving it
elsewhere, Bae has the reproducer, they can check if moving it fixes
their issue or not.

thanks,

greg k-h

  reply	other threads:[~2026-03-20 15:05 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 [this message]
2026-03-20 15:21     ` paeyz
2026-03-20 15:40       ` Greg KH
2026-03-20 15:52         ` [PATCH v2] adfs: validate nzones in adfs_validate_bblk() paeyz
2026-03-20 16:04           ` 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=2026032021-renewable-control-9c81@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=iwasbaeyz@gmail.com \
    --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