From: Brian Foster <bfoster@redhat.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, Dave Chinner <david@fromorbit.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/3] filemap: Handle sibling entries in filemap_get_read_batch()
Date: Mon, 20 Jun 2022 06:15:46 -0400 [thread overview]
Message-ID: <YrBI0jIzeyksEVyp@bfoster> (raw)
In-Reply-To: <20220619151143.1054746-3-willy@infradead.org>
On Sun, Jun 19, 2022 at 04:11:42PM +0100, Matthew Wilcox (Oracle) wrote:
> If a read races with an invalidation followed by another read, it is
> possible for a folio to be replaced with a higher-order folio. If that
> happens, we'll see a sibling entry for the new folio in the next iteration
> of the loop. This manifests as a NULL pointer dereference while holding
> the RCU read lock.
>
> Handle this by simply returning. The next call will find the new folio
> and handle it correctly. The other ways of handling this rare race are
> more complex and it's just not worth it.
>
> Reported-by: Dave Chinner <david@fromorbit.com>
> Reported-by: Brian Foster <bfoster@redhat.com>
> Debugged-by: Brian Foster <bfoster@redhat.com>
> Tested-by: Brian Foster <bfoster@redhat.com>
> Fixes: cbd59c48ae2b ("mm/filemap: use head pages in generic_file_buffered_read")
> Cc: stable@vger.kernel.org
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
This has survived my testing for several days now. I think I grok the
fix and analysis that lead to it, so FWIW:
Reviewed-by: Brian Foster <bfoster@redhat.com>
> mm/filemap.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 577068868449..ffdfbc8b0e3c 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2385,6 +2385,8 @@ static void filemap_get_read_batch(struct address_space *mapping,
> continue;
> if (xas.xa_index > max || xa_is_value(folio))
> break;
> + if (xa_is_sibling(folio))
> + break;
> if (!folio_try_get_rcu(folio))
> goto retry;
>
> --
> 2.35.1
>
next prev parent reply other threads:[~2022-06-20 10:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-19 15:11 [PATCH 0/3] Fixes for 5.19b Matthew Wilcox (Oracle)
2022-06-19 15:11 ` [PATCH 1/3] filemap: Correct the conditions for marking a folio as accessed Matthew Wilcox (Oracle)
2022-06-20 6:25 ` Christoph Hellwig
2022-06-27 9:13 ` [filemap] 91fd26c76b: phoronix-test-suite.fio.SequentialRead.LinuxAIO.Yes.No.4KB.DefaultTestDirectory.mb_s -8.9% regression kernel test robot
2022-06-27 9:13 ` kernel test robot
2022-06-30 7:29 ` Major btrfs fiemap slowdown on file with many extents once in cache (RCU stalls?) (Was: [PATCH 1/3] filemap: Correct the conditions for marking a folio as accessed) Dominique MARTINET
2022-06-30 14:37 ` Theodore Ts'o
2022-06-30 22:43 ` Dominique MARTINET
2022-07-01 1:55 ` Yu Kuai
2022-07-07 8:42 ` Dominique MARTINET
2022-06-19 15:11 ` [PATCH 2/3] filemap: Handle sibling entries in filemap_get_read_batch() Matthew Wilcox (Oracle)
2022-06-20 10:15 ` Brian Foster [this message]
2022-06-19 15:11 ` [PATCH 3/3] mm: Clear page->private when splitting or migrating a page Matthew Wilcox (Oracle)
2022-06-20 6:41 ` Xiubo Li
2022-06-20 23:42 ` Xiubo Li
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=YrBI0jIzeyksEVyp@bfoster \
--to=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
--cc=willy@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.