From: Sidhartha Kumar <sidhartha.kumar@oracle.com>
To: Jeongjun Park <aha310510@gmail.com>,
muchun.song@linux.dev, osalvador@suse.de, david@redhat.com,
akpm@linux-foundation.org
Cc: leitao@debian.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
syzbot+417aeb05fd190f3a6da9@syzkaller.appspotmail.com
Subject: Re: [PATCH] mm/hugetlb: add missing hugetlb_lock in __unmap_hugepage_range()
Date: Fri, 22 Aug 2025 11:19:33 -0400 [thread overview]
Message-ID: <fd39be50-90ab-4b25-ac1e-10930aa52b5f@oracle.com> (raw)
In-Reply-To: <20250822055857.1142454-1-aha310510@gmail.com>
On 8/22/25 1:58 AM, Jeongjun Park wrote:
> When restoring a reservation for an anonymous page, we need to check to
> freeing a surplus. However, __unmap_hugepage_range() causes data race
> because it reads h->surplus_huge_pages without the protection of
> hugetlb_lock.
>
> Therefore, we need to add missing hugetlb_lock.
>
Makes sense as alloc_surplus_hugetlb_folio() takes the hugetlb_lock when
reading the hstate.
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> Reported-by: syzbot+417aeb05fd190f3a6da9@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=417aeb05fd190f3a6da9
> Fixes: df7a6d1f6405 ("mm/hugetlb: restore the reservation if needed")
> Signed-off-by: Jeongjun Park <aha310510@gmail.com>
> ---
> mm/hugetlb.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 753f99b4c718..e8d95a314df2 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5951,6 +5951,8 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
> * If there we are freeing a surplus, do not set the restore
> * reservation bit.
> */
> + spin_lock_irq(&hugetlb_lock);
> +
> if (!h->surplus_huge_pages && __vma_private_lock(vma) &&
> folio_test_anon(folio)) {
> folio_set_hugetlb_restore_reserve(folio);
> @@ -5958,6 +5960,7 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
> adjust_reservation = true;
> }
>
> + spin_unlock_irq(&hugetlb_lock);
> spin_unlock(ptl);
>
> /*
> --
>
next prev parent reply other threads:[~2025-08-22 15:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 5:58 Jeongjun Park
2025-08-22 15:19 ` Sidhartha Kumar [this message]
2025-08-23 1:07 ` Andrew Morton
2025-08-23 8:52 ` Giorgi Tchankvetadze
2025-08-23 14:40 ` Jeongjun Park
2025-08-23 15:07 ` Jeongjun Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd39be50-90ab-4b25-ac1e-10930aa52b5f@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=aha310510@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=syzbot+417aeb05fd190f3a6da9@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox