
From: Ma Wupeng <mawupeng1@huawei.com> hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S CVE: NA ------------------------------------------ Memory allocation from buddy system will fallback to unmirrored memory if mirrored memory is not enough and reliable memory fallback is closed. ___GFP_NOFAIL flag will be checked in prepare_before_alloc(). Fixes: 45bd608ef89e ("mm: Introduce watermark check for memory reliable") Signed-off-by: Ma Wupeng <mawupeng1@huawei.com> Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- mm/page_alloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 571bfdecd5a0c..fd4354d9ebad0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4651,7 +4651,13 @@ static inline bool prepare_before_alloc(gfp_t *gfp_mask, unsigned int order) if (!mem_reliable_is_enabled()) return true; + if (*gfp_mask & __GFP_NOFAIL) + return true; + if (gfp_ori & ___GFP_RELIABILITY) { + if (!(gfp_ori & __GFP_HIGHMEM) || !(gfp_ori & __GFP_MOVABLE)) + return true; + if (mem_reliable_watermark_ok(1 << order)) { *gfp_mask |= ___GFP_RELIABILITY; return true; -- 2.25.1