From: Tang Yizhou tangyizhou@huawei.com
ascend inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4EUVI CVE: NA
-------------------------------------------------
If all the processes in an sp group are exiting, the sp areas are also freed. We need to clear VM_SHAREPOOL flag for the k2u sp areas, otherwise __vunmap will fail later.
Signed-off-by: Tang Yizhou tangyizhou@huawei.com Signed-off-by: Zhou Guanghui zhouguanghui1@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Reviewed-by: Ding Tianhong dingtianhong@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- mm/share_pool.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/mm/share_pool.c b/mm/share_pool.c index 19580b85d77fb..64d9d9198830d 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -1641,6 +1641,19 @@ static struct sp_area *__find_sp_area(unsigned long addr) return n; }
+static bool vmalloc_area_clr_flag(unsigned long kva, unsigned long flags) +{ + struct vm_struct *area; + + area = find_vm_area((void *)kva); + if (area) { + area->flags &= ~flags; + return true; + } + + return false; +} + /* * Free the VA region starting from addr to the share pool */ @@ -1669,6 +1682,11 @@ static void sp_free_area(struct sp_area *spa) } }
+ if (spa->kva) { + if (!vmalloc_area_clr_flag(spa->kva, VM_SHAREPOOL)) + pr_debug("clear spa->kva %ld is not valid\n", spa->kva); + } + spa_dec_usage(spa); if (spa->spg != spg_none) list_del(&spa->link); @@ -2630,19 +2648,6 @@ static bool vmalloc_area_set_flag(unsigned long kva, unsigned long flags) return false; }
-static bool vmalloc_area_clr_flag(unsigned long kva, unsigned long flags) -{ - struct vm_struct *area; - - area = find_vm_area((void *)kva); - if (area) { - area->flags &= ~flags; - return true; - } - - return false; -} - struct sp_k2u_context { unsigned long kva; unsigned long kva_aligned;