Files
kernel_arpi/include/linux
Matthew Wilcox (Oracle) 07378b0991 xarray: Fix early termination of xas_for_each_marked
commit 7e934cf5ac upstream.

xas_for_each_marked() is using entry == NULL as a termination condition
of the iteration. When xas_for_each_marked() is used protected only by
RCU, this can however race with xas_store(xas, NULL) in the following
way:

TASK1                                   TASK2
page_cache_delete()         	        find_get_pages_range_tag()
                                          xas_for_each_marked()
                                            xas_find_marked()
                                              off = xas_find_chunk()

  xas_store(&xas, NULL)
    xas_init_marks(&xas);
    ...
    rcu_assign_pointer(*slot, NULL);
                                              entry = xa_entry(off);

And thus xas_for_each_marked() terminates prematurely possibly leading
to missed entries in the iteration (translating to missing writeback of
some pages or a similar problem).

If we find a NULL entry that has been marked, skip it (unless we're trying
to allocate an entry).

Reported-by: Jan Kara <jack@suse.cz>
CC: stable@vger.kernel.org
Fixes: ef8e5717db ("page cache: Convert delete_batch to XArray")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-17 10:50:18 +02:00
..
2019-09-17 10:27:46 -07:00
2020-02-19 19:53:09 +01:00
2019-09-16 09:56:27 -07:00
2020-02-11 04:35:52 -08:00
2019-08-28 21:17:12 -06:00
2019-09-05 19:52:33 -06:00
2020-03-25 08:25:58 +01:00
2020-03-25 08:25:58 +01:00
2019-09-05 11:40:54 +02:00
2019-09-24 15:54:08 -07:00
2019-10-02 06:36:50 -07:00
2019-09-07 04:28:05 -03:00
2019-12-13 08:42:53 +01:00
2019-09-02 11:43:54 +01:00
2019-09-05 12:32:05 +02:00
2019-12-13 08:43:18 +01:00
2020-03-18 07:17:46 +01:00
2019-08-23 16:39:26 +01:00
2020-04-17 10:50:12 +02:00
2020-04-02 15:11:00 +02:00
2019-10-31 14:01:40 -07:00
2019-09-25 17:51:41 -07:00
2019-09-07 21:42:25 +02:00
2019-10-02 10:06:45 +02:00
2019-08-30 07:27:17 -07:00
2020-03-25 08:25:58 +01:00
2020-04-02 15:11:00 +02:00