From dab3f4737d75043e7bac73bfe0dec1e22a073989 Mon Sep 17 00:00:00 2001 From: Ma Wupeng Date: Thu, 18 Aug 2022 11:35:56 +0800 Subject: [PATCH] mm: Update reliable flag in memory allocaion for reliable task only in task context hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S CVE: NA -------------------------------- Since interrupt may occupy reliable task's context and its current->flags will have PF_RELIABLE and this will lead to redirect it's memory allocation to mirrored region. In order to solve this problem, update reliable task's gfp flag can only happen in normal task context by checking in_task(). Signed-off-by: Ma Wupeng Reviewed-by: Kefeng Wang --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5fdbe4ecfb58..24116b7828f5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5182,6 +5182,9 @@ static inline void prepare_before_alloc(gfp_t *gfp_mask) if (!zone_movable) goto clear_flag; + if (!in_task()) + return; + if ((current->flags & PF_RELIABLE) || is_global_init(current)) *gfp_mask |= GFP_RELIABLE; -- GitLab