* [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte
@ 2022-07-09 9:26 Miaohe Lin
2022-07-11 10:18 ` Muchun Song
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Miaohe Lin @ 2022-07-09 9:26 UTC (permalink / raw)
To: akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel, linmiaohe
When alloc_huge_page fails, *pagep is set to NULL without put_page first.
So the hugepage indicated by *pagep is leaked.
Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/hugetlb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 06c2d86b1ba3..598c37279fee 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5962,6 +5962,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
page = alloc_huge_page(dst_vma, dst_addr, 0);
if (IS_ERR(page)) {
+ put_page(*pagep);
ret = -ENOMEM;
*pagep = NULL;
goto out;
--
2.23.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte
2022-07-09 9:26 [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte Miaohe Lin
@ 2022-07-11 10:18 ` Muchun Song
2022-07-11 21:02 ` Mike Kravetz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Muchun Song @ 2022-07-11 10:18 UTC (permalink / raw)
To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel
On Sat, Jul 09, 2022 at 05:26:29PM +0800, Miaohe Lin wrote:
> When alloc_huge_page fails, *pagep is set to NULL without put_page first.
> So the hugepage indicated by *pagep is leaked.
>
> Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: Muchun Song <songmuchun@bytedance.com>
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte
2022-07-09 9:26 [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte Miaohe Lin
2022-07-11 10:18 ` Muchun Song
@ 2022-07-11 21:02 ` Mike Kravetz
2022-07-12 3:00 ` Baolin Wang
2022-07-12 8:12 ` Anshuman Khandual
3 siblings, 0 replies; 5+ messages in thread
From: Mike Kravetz @ 2022-07-11 21:02 UTC (permalink / raw)
To: Miaohe Lin; +Cc: akpm, songmuchun, linux-mm, linux-kernel
On 07/09/22 17:26, Miaohe Lin wrote:
> When alloc_huge_page fails, *pagep is set to NULL without put_page first.
> So the hugepage indicated by *pagep is leaked.
>
> Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> mm/hugetlb.c | 1 +
> 1 file changed, 1 insertion(+)
Thanks for finding and fixing!
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 06c2d86b1ba3..598c37279fee 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5962,6 +5962,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
>
> page = alloc_huge_page(dst_vma, dst_addr, 0);
> if (IS_ERR(page)) {
> + put_page(*pagep);
> ret = -ENOMEM;
> *pagep = NULL;
> goto out;
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte
2022-07-09 9:26 [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte Miaohe Lin
2022-07-11 10:18 ` Muchun Song
2022-07-11 21:02 ` Mike Kravetz
@ 2022-07-12 3:00 ` Baolin Wang
2022-07-12 8:12 ` Anshuman Khandual
3 siblings, 0 replies; 5+ messages in thread
From: Baolin Wang @ 2022-07-12 3:00 UTC (permalink / raw)
To: Miaohe Lin, akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel
On 7/9/2022 5:26 PM, Miaohe Lin wrote:
> When alloc_huge_page fails, *pagep is set to NULL without put_page first.
> So the hugepage indicated by *pagep is leaked.
>
> Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
> mm/hugetlb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 06c2d86b1ba3..598c37279fee 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5962,6 +5962,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
>
> page = alloc_huge_page(dst_vma, dst_addr, 0);
> if (IS_ERR(page)) {
> + put_page(*pagep);
> ret = -ENOMEM;
> *pagep = NULL;
> goto out;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte
2022-07-09 9:26 [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte Miaohe Lin
` (2 preceding siblings ...)
2022-07-12 3:00 ` Baolin Wang
@ 2022-07-12 8:12 ` Anshuman Khandual
3 siblings, 0 replies; 5+ messages in thread
From: Anshuman Khandual @ 2022-07-12 8:12 UTC (permalink / raw)
To: Miaohe Lin, akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel
On 7/9/22 14:56, Miaohe Lin wrote:
> When alloc_huge_page fails, *pagep is set to NULL without put_page first.
> So the hugepage indicated by *pagep is leaked.
>
> Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> mm/hugetlb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 06c2d86b1ba3..598c37279fee 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5962,6 +5962,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
>
> page = alloc_huge_page(dst_vma, dst_addr, 0);
> if (IS_ERR(page)) {
> + put_page(*pagep);
> ret = -ENOMEM;
> *pagep = NULL;
> goto out;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-12 8:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 9:26 [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte Miaohe Lin
2022-07-11 10:18 ` Muchun Song
2022-07-11 21:02 ` Mike Kravetz
2022-07-12 3:00 ` Baolin Wang
2022-07-12 8:12 ` Anshuman Khandual
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).