From 295fbc30b2c07e673d5608936734a3ef1b628555 Mon Sep 17 00:00:00 2001 From: Ma Wupeng Date: Thu, 18 Aug 2022 11:35:40 +0800 Subject: [PATCH] mm: Clear GFP_RELIABLE if the conditions are not met hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S CVE: NA -------------------------------- Memory reliable only handle memory allocation from movable zone. GFP_RELIABLE will be removed if the conditions are not met. Signed-off-by: Ma Wupeng Reviewed-by: Kefeng Wang --- mm/page_alloc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 732304f03fda..74affafb8d48 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5144,11 +5144,26 @@ EXPORT_SYMBOL_GPL(__alloc_pages_bulk); static inline void prepare_before_alloc(gfp_t *gfp_mask) { + bool zone_movable; + if (!mem_reliable_is_enabled()) - return; + goto clear_flag; + + /* + * memory reliable only handle memory allocation from movable zone + * (force alloc from non-movable zone or force alloc from movable + * zone) to get total isolation. + */ + zone_movable = gfp_zone(*gfp_mask & ~GFP_RELIABLE) == ZONE_MOVABLE; + if (!zone_movable) + goto clear_flag; if ((current->flags & PF_RELIABLE) || is_global_init(current)) *gfp_mask |= GFP_RELIABLE; + + return; +clear_flag: + *gfp_mask &= ~GFP_RELIABLE; } /* -- GitLab