page_alloc-fix-freeing-non-compound-pages.patch removed from -mm tree
The patch titled
Subject: mm/page_alloc.c: fix freeing non-compound pages
has been removed from the -mm tree. Its filename was
page_alloc-fix-freeing-non-compound-pages.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: "Matthew Wilcox (Oracle)" <[email protected]>
Subject: mm/page_alloc.c: fix freeing non-compound pages
Here is a very rare race which leaks memory:
Page P0 is allocated to the page cache. Page P1 is free.
Thread A Thread B Thread Cfind_get_entry():xas_load() returns P0
Removes P0 from page cache P0 finds its buddy P1
alloc_pages(GFP_KERNEL, 1) returns P0 P0 has refcount 1page_cache_get_speculative(P0)
P0 has refcount 2
__free_pages(P0) P0 has refcount 1
put_page(P0)
P1 is not freed
Fix this by freeing all the pages in __free_pages() that won't be freed by the call to put_page(). It's usually not a good idea to split a page, but this is a very unlikely scenario.
---
lib/Kconfig.debug | 9 ++++++++ lib/Makefile | 1 lib/test_free_pages.c | 42 ++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 3 ++ 4 files changed, 55 insertions(+)
lib/Kconfig.debug renamed from lib/Kconfig.debug~page_alloc-fix-freeing-non-compound-pages +9 -0
@@ -2367,6 +2367,15 @@ config TEST_HMM If unsure, say N. +config TEST_FREE_PAGES + tristate "Test freeing pages" + help + Test that a memory leak does not occur due to a race between + freeing a block of pages and a speculative page reference. + Loading this module is safe if your kernel has the bug fixed. + If the bug is not fixed, it will leak gigabytes of memory and + probably OOM your system. + config TEST_FPU tristate "Test floating point operations in kernel space" depends on X86 && !KCOV_INSTRUMENT_ALL
lib/Makefile renamed from lib/Makefile~page_alloc-fix-freeing-non-compound-pages +1 -0
@@ -101,6 +101,7 @@ obj-$(CONFIG_TEST_BLACKHOLE_DEV) += test obj-$(CONFIG_TEST_MEMINIT) += test_meminit.o obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o obj-$(CONFIG_TEST_HMM) += test_hmm.o +obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o # # CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns
lib/test_free_pages.c new file +42 -0
42 lines not on this page · raw message
mm/page_alloc.c renamed from mm/page_alloc.c~page_alloc-fix-freeing-non-compound-pages +3 -0
@@ -4952,6 +4952,9 @@ void __free_pages(struct page *page, uns {if (put_page_testzero (page))free_the_page (page, order); +else if (!PageHead (page)) +while (order-- >0 ) +free_the_page (page + (1 << order), order); }EXPORT_SYMBOL (__free_pages);
_
Patches currently in -mm which might be from [email protected] are
xarray-add-xa_get_order.patch
xarray-add-xas_split.patch
xarray-add-xas_split-fix-2.patch xarray-add-xas_split-fix-3patch.patch mm-filemap-fix-storing-to-a-thp-shadow-entry.patch mm-filemap-fix-page-cache-removal-for-arbitrary-sized-thps.patch mm-memory-remove-page-fault-assumption-of-compound-page-size.patch mm-memory-remove-page-fault-assumption-of-compound-page-size-fix.patch mm-page_owner-change-split_page_owner-to-take-a-count.patch mm-huge_memory-fix-page_trans_huge_mapcount-assumption-of-thp-size.patch mm-huge_memory-fix-can_split_huge_page-assumption-of-thp-size.patch mm-rmap-fix-assumptions-of-thp-size.patch mm-truncate-fix-truncation-for-pages-of-arbitrary-size.patch mm-page-writeback-support-tail-pages-in-wait_for_stable_page.patch mm-vmscan-allow-arbitrary-sized-pages-to-be-paged-out.patch fs-add-a-filesystem-flag-for-thps.patch fs-do-not-update-nr_thps-for-mappings-which-support-thps.patch mm-readahead-add-define_readahead.patch mm-readahead-make-page_cache_ra_unbounded-take-a-readahead_control.patch mm-readahead-make-do_page_cache_ra-take-a-readahead_control.patch mm-readahead-add-page_cache_sync_ra-and-page_cache_async_ra.patch mm-rename-page_order-to-buddy_order.patch ramfs-fix-nommu-mmap-with-gaps-in-the-page-cache.patch harden-autofs-ioctl-table.patch mm-update-the-documentation-for-vfree.patch