[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240930100234.f7e91af05adeea036e0be8cc@linux-foundation.org>
Date: Mon, 30 Sep 2024 10:02:34 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Gianfranco Trad <gianf.trad@...il.com>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, skhan@...uxfoundation.org,
syzbot+4089e577072948ac5531@...kaller.appspotmail.com, willy@...radead.org
Subject: Re: [PATCH v2] Fix NULL pointer dereference in read_cache_folio
On Mon, 30 Sep 2024 11:02:26 +0200 Gianfranco Trad <gianf.trad@...il.com> wrote:
> Add check on filler to prevent NULL pointer dereference condition in
> read_cache_folio[1].
>
> [1] https://syzkaller.appspot.com/bug?extid=4089e577072948ac5531
Test case https://syzkaller.appspot.com/x/repro.c?x=10a0d880580000
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 4f3753f0a158..88de8029133c 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2360,6 +2360,8 @@ static int filemap_read_folio(struct file *file, filler_t filler,
> /* Start the actual read. The read will unlock the page. */
> if (unlikely(workingset))
> psi_memstall_enter(&pflags);
> + if (!filler)
> + return -EIO;
> error = filler(file, folio);
> if (unlikely(workingset))
> psi_memstall_leave(&pflags);
do_read_cache_folio() already handles a NULL filler (from
freader_get_folio()'s read_cache_folio() call).
if (!filler)
filler = mapping->a_ops->read_folio;
so I'm suspecting that an appropriate fix is to teach the underlying
address_space_operations (appears to be from /proc/pid/maps) to
implement ->read_folio().
Powered by blists - more mailing lists