[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190128161200.55107-153-sashal@kernel.org>
Date: Mon, 28 Jan 2019 11:11:43 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Miles Chen <miles.chen@...iatek.com>,
Joe Perches <joe@...ches.com>,
Matthew Wilcox <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Sasha Levin <sashal@...nel.org>, linux-mm@...ck.org
Subject: [PATCH AUTOSEL 4.14 153/170] mm/page_owner: clamp read count to PAGE_SIZE
From: Miles Chen <miles.chen@...iatek.com>
[ Upstream commit c8f61cfc871fadfb73ad3eacd64fda457279e911 ]
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@...ux-foundation.org: use min_t()]
Link: http://lkml.kernel.org/r/1541091607-27402-1-git-send-email-miles.chen@mediatek.com
Signed-off-by: Miles Chen <miles.chen@...iatek.com>
Acked-by: Michal Hocko <mhocko@...e.com>
Cc: Joe Perches <joe@...ches.com>
Cc: Matthew Wilcox <willy@...radead.org>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
mm/page_owner.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/page_owner.c b/mm/page_owner.c
index a71fe4c623ef..7232c6e24234 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;
--
2.19.1
Powered by blists - more mailing lists