Skip to content

Commit 1412ecb

Browse files
x-y-zakpm00
authored andcommitted
mm/huge_memory: check new folio order when split a folio
A folio can only be split into lower orders. Since there are no new_order checks in debugfs, any new_order can be passed via debugfs into split_huge_page_to_list_to_order(). Check new_order to make sure it is smaller than input folio order. Link: https://lkml.kernel.org/r/[email protected] Fixes: c010d47 ("mm: thp: split huge page to any lower order pages") Signed-off-by: Zi Yan <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/linux-mm/[email protected]/ Cc: David Hildenbrand <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Yang Shi <[email protected]> Cc: Yu Zhao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d221dd5 commit 1412ecb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/huge_memory.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,6 +3052,9 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
30523052
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
30533053
VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);
30543054

3055+
if (new_order >= folio_order(folio))
3056+
return -EINVAL;
3057+
30553058
/* Cannot split anonymous THP to order-1 */
30563059
if (new_order == 1 && folio_test_anon(folio)) {
30573060
VM_WARN_ONCE(1, "Cannot split to order-1 folio");

0 commit comments

Comments
 (0)