提交 028ff973 编写于 作者: S SeongJae Park 提交者: Yang Yingliang

mm/page_idle.c: skip offline pages

mainline inclusion
from mainline-v5.8-rc1
commit 92fb1db2
category: bugfix
bugzilla: 37584
CVE: NA

-------------------------------------------------

'Idle page tracking' users can pass random pfn that might be mapped to an
offline page.  To avoid accessing such pages, this commit modifies the
'page_idle_get_page()' to use 'pfn_to_online_page()' instead of
'pfn_valid()' and 'pfn_to_page()' combination, so that the pfn mapped to
an offline page can be skipped.
Reported-by: NDavid Hildenbrand <david@redhat.com>
Signed-off-by: NSeongJae Park <sjpark@amazon.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: NDavid Hildenbrand <david@redhat.com>
Reviewed-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
Link: http://lkml.kernel.org/r/20200605092502.18018-2-sjpark@amazon.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 023faff7
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/memory_hotplug.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/mmzone.h> #include <linux/mmzone.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
...@@ -30,13 +31,9 @@ ...@@ -30,13 +31,9 @@
*/ */
static struct page *page_idle_get_page(unsigned long pfn) static struct page *page_idle_get_page(unsigned long pfn)
{ {
struct page *page; struct page *page = pfn_to_online_page(pfn);
struct zone *zone; struct zone *zone;
if (!pfn_valid(pfn))
return NULL;
page = pfn_to_page(pfn);
if (!page || !PageLRU(page) || if (!page || !PageLRU(page) ||
!get_page_unless_zero(page)) !get_page_unless_zero(page))
return NULL; return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册