From: Miles Chen <miles.chen@xxxxxxxxxxxx> Subject: mm/page_owner: clamp read count to PAGE_SIZE The (root-only) page owner read might allocate a large size of memory with a large read count. Allocation fails can easily occur when doing high order allocations. Clamp buffer size to PAGE_SIZE to avoid arbitrary size allocation and avoid allocation fails due to high order allocation. [akpm@xxxxxxxxxxxxxxxxxxxx: use min_t()] Link: http://lkml.kernel.org/r/1541091607-27402-1-git-send-email-miles.chen@xxxxxxxxxxxx Signed-off-by: Miles Chen <miles.chen@xxxxxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Cc: Joe Perches <joe@xxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/mm/page_owner.c~mm-page_owner-clamp-read-count-to-page_size +++ a/mm/page_owner.c @@ -351,6 +351,7 @@ print_page_owner(char __user *buf, size_ .skip = 0 }; + count = min_t(size_t, count, PAGE_SIZE); kbuf = kmalloc(count, GFP_KERNEL); if (!kbuf) return -ENOMEM; _