Re: [PATCH v2] Fix NULL pointer dereference in read_cache_folio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 30 Sep 2024 11:02:26 +0200 Gianfranco Trad <gianf.trad@xxxxxxxxx> 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().




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux