aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Chen <[email protected]>2018-12-28 00:33:21 -0800
committerLinus Torvalds <[email protected]>2018-12-28 12:11:46 -0800
commitc8f61cfc871fadfb73ad3eacd64fda457279e911 (patch)
treee66a7f8da6dc30887b8ab19afa71127a0493a84d
parent4e45f712d82c6b7a37e02faf388173ad12ab464d (diff)
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. [[email protected]: use min_t()] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Miles Chen <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Joe Perches <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--mm/page_owner.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 87bc0dfdb52b..28b06524939f 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -351,6 +351,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn,
.skip = 0
};
+ count = min_t(size_t, count, PAGE_SIZE);
kbuf = kmalloc(count, GFP_KERNEL);
if (!kbuf)
return -ENOMEM;