From a1bdc2e22aa6a9010cf8c02b1ec2d2c4231f9cc3 Mon Sep 17 00:00:00 2001 From: Ma Wupeng Date: Fri, 11 Nov 2022 09:32:27 +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 d9a5402b1552..1313c112a30c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5148,11 +5148,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