From 9975c8ea81c98fc334a64849164d3625148c2d21 Mon Sep 17 00:00:00 2001 From: zhong jiang Date: Tue, 30 Apr 2019 14:58:17 +0800 Subject: [PATCH] mm/hugetlb: release lock before put_page to avoid deadlock euler inclusion commit NA category: bugfix bugzilla: NA CVE: NA ------------------------------------------------ Commit 9980d744a042 ("mm, hugetlb: get rid of surplus page accounting tricks") introduce the deadloop issue. We hold the hugetlb_lock to deal with put_page, And if the refcount drop to zero, we will call free_huge_page to free the page to buddy system. Unfortunatlly, it also need to get the lock the operation. The patch just release the lock before put_page. hence it will avoid the deadloop. Fixes: 9980d744a042 ("mm, hugetlb: get rid of surplus page accounting tricks") Signed-off-by: zhong jiang Reviewed-by: Jing Xiangfeng Signed-off-by: Yang Yingliang --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 5ba9524376df..d467046ed100 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1572,8 +1572,9 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, */ if (h->surplus_huge_pages >= h->nr_overcommit_huge_pages) { SetPageHugeTemporary(page); + spin_unlock(&hugetlb_lock); put_page(page); - page = NULL; + return NULL; } else { h->surplus_huge_pages++; h->surplus_huge_pages_node[page_to_nid(page)]++; -- GitLab