From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@lst.de>
Cc: akpm@linux-foundation.org, jack@suse.cz,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
dhowells@redhat.com, marc.dionne@auristor.com,
linux-afs@lists.infradead.org,
syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com
Subject: Re: [PATCH 1/2] filemap: fix the conditional folio_put in filemap_fault
Date: Wed, 3 May 2023 17:57:06 +0200 [thread overview]
Message-ID: <20230503155706.3j3y3nlfh6aglhhm@quack3> (raw)
In-Reply-To: <20230503154526.1223095-1-hch@lst.de>
On Wed 03-05-23 17:45:25, Christoph Hellwig wrote:
> folio can't be NULL here now that __filemap_get_folio returns an
> ERR_PTR. Remove the conditional folio_put after the out_retry
> label and add a new label for the cases where we have a valid folio.
>
> Fixes: 66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio")
> Reported-by: syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good to me. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> mm/filemap.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index a34abfe8c65430..ae597f63a9bc54 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -3298,7 +3298,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
> }
>
> if (!lock_folio_maybe_drop_mmap(vmf, folio, &fpin))
> - goto out_retry;
> + goto out_retry_put_folio;
>
> /* Did it get truncated? */
> if (unlikely(folio->mapping != mapping)) {
> @@ -3334,7 +3334,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
> */
> if (fpin) {
> folio_unlock(folio);
> - goto out_retry;
> + goto out_retry_put_folio;
> }
> if (mapping_locked)
> filemap_invalidate_unlock_shared(mapping);
> @@ -3363,7 +3363,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
> fpin = maybe_unlock_mmap_for_io(vmf, fpin);
> error = filemap_read_folio(file, mapping->a_ops->read_folio, folio);
> if (fpin)
> - goto out_retry;
> + goto out_retry_put_folio;
> folio_put(folio);
>
> if (!error || error == AOP_TRUNCATED_PAGE)
> @@ -3372,14 +3372,14 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
>
> return VM_FAULT_SIGBUS;
>
> +out_retry_put_folio:
> + folio_put(folio);
> out_retry:
> /*
> * We dropped the mmap_lock, we need to return to the fault handler to
> * re-find the vma and come back and find our hopefully still populated
> * page.
> */
> - if (folio)
> - folio_put(folio);
> if (mapping_locked)
> filemap_invalidate_unlock_shared(mapping);
> if (fpin)
> --
> 2.39.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-05-03 15:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 15:45 Christoph Hellwig
2023-05-03 15:45 ` [PATCH 2/2] afs: fix the afs_dir_get_folio return value Christoph Hellwig
2023-05-03 15:54 ` Jan Kara
2023-05-03 15:48 ` [PATCH 1/2] filemap: fix the conditional folio_put in filemap_fault Matthew Wilcox
2023-05-03 15:49 ` Christoph Hellwig
2023-05-04 3:34 ` Matthew Wilcox
2023-05-03 15:57 ` Jan Kara [this message]
2023-05-03 18:55 ` [PATCH 2/2] afs: fix the afs_dir_get_folio return value David Howells
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=20230503155706.3j3y3nlfh6aglhhm@quack3 \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=linux-afs@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=marc.dionne@auristor.com \
--cc=syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com \
/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