mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-25 20:05:39 +00:00
filemap: Handle sibling entries in filemap_get_read_batch()
commitcb995f4eeb
upstream. 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> Reviewed-by: Brian Foster <bfoster@redhat.com> Fixes:cbd59c48ae
("mm/filemap: use head pages in generic_file_buffered_read") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8a79182e7a
commit
a66f131d30
1 changed files with 2 additions and 0 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue