提交 faf89705 编写于 作者: L Liu Xiang 提交者: Yang Yingliang

mm: hugetlb: fix type of delta parameter and related local variables in gather_surplus_pages()

mainline inclusion
from mainline-v5.11-rc1
commit 0a4f3d1b
category: bugfix
bugzilla: NA
CVE: NA

-----------------------------------------------

On 64-bit machine, delta variable in hugetlb_acct_memory() may be larger
than 0xffffffff, but gather_surplus_pages() can only use the low 32-bit
value now.  So we need to fix type of delta parameter and related local
variables in gather_surplus_pages().

Link: https://lkml.kernel.org/r/1605793733-3573-1-git-send-email-liu.xiang@zlingsmart.comReported-by: NMa Chenggong <ma.chenggong@zlingsmart.com>
Signed-off-by: NLiu Xiang <liu.xiang@zlingsmart.com>
Signed-off-by: NPan Jiagen <pan.jiagen@zlingsmart.com>
Reviewed-by: NMike Kravetz <mike.kravetz@oracle.com>
Cc: Liu Xiang <liuxiang_1999@126.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>

conflict:
	mm/hugetlb.c
Signed-off-by: NTong Tiangen <tongtiangen@huawei.com>
Reviewed-by: NChen Wandun <chenwandun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 946a53b7
...@@ -1822,12 +1822,13 @@ struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma, ...@@ -1822,12 +1822,13 @@ struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
* Increase the hugetlb pool such that it can accommodate a reservation * Increase the hugetlb pool such that it can accommodate a reservation
* of size 'delta'. * of size 'delta'.
*/ */
static int gather_surplus_pages(struct hstate *h, int delta) static int gather_surplus_pages(struct hstate *h, long delta)
{ {
struct list_head surplus_list; struct list_head surplus_list;
struct page *page, *tmp; struct page *page, *tmp;
int ret, i; int ret;
int needed, allocated; long i;
long needed, allocated;
bool alloc_ok = true; bool alloc_ok = true;
needed = (h->resv_huge_pages + delta) - h->free_huge_pages; needed = (h->resv_huge_pages + delta) - h->free_huge_pages;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册