linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Ma Ke <make24@iscas.ac.cn>
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] filemap: fix error pointer dereference in filemap_fault()
Date: Tue, 16 Jul 2024 03:30:06 +0100	[thread overview]
Message-ID: <ZpXbLr0JeybnV6af@casper.infradead.org> (raw)
In-Reply-To: <20240716022518.430237-1-make24@iscas.ac.cn>

On Tue, Jul 16, 2024 at 10:25:18AM +0800, Ma Ke wrote:
> This code calls folio_put() on an error pointer which will lead to a
> crash.  Check for both error pointers and NULL pointers before calling
> folio_put().

Have you observed this, or do you just think this can happen?

If the former, please share the crash.
If the latter, please document the path which can lead to this
happening.

> Fixes: 38a55db9877c ("filemap: Handle error return from __filemap_get_folio()")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  mm/filemap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 657bcd887fdb..cd26617d8987 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -3420,7 +3420,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
>  	 * re-find the vma and come back and find our hopefully still populated
>  	 * page.
>  	 */
> -	if (!IS_ERR(folio))
> +	if (!IS_ERR_OR_NULL(folio))
>  		folio_put(folio);
>  	if (mapping_locked)
>  		filemap_invalidate_unlock_shared(mapping);
> -- 
> 2.25.1
> 


      reply	other threads:[~2024-07-16  2:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16  2:25 [PATCH] filemap: fix error pointer dereference in filemap_fault() Ma Ke
2024-07-16  2:30 ` Matthew Wilcox [this message]

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=ZpXbLr0JeybnV6af@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=make24@iscas.ac.cn \
    /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;
as well as URLs for NNTP newsgroup(s).