From: Usama Arif <usama.arif@bytedance.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
muchun.song@linux.dev, mike.kravetz@oracle.com,
songmuchun@bytedance.com, fam.zheng@bytedance.com,
liangma@liangbit.com, punit.agrawal@bytedance.com,
Usama Arif <usama.arif@bytedance.com>
Subject: [PATCH] mm: hugetlb: Only prep and add allocated folios for non-gigantic pages
Date: Mon, 9 Oct 2023 15:56:05 +0100 [thread overview]
Message-ID: <20231009145605.2150897-1-usama.arif@bytedance.com> (raw)
Calling prep_and_add_allocated_folios when allocating gigantic pages
at boot time causes the kernel to crash as folio_list is empty
and iterating it causes a NULL pointer dereference. Call this only
for non-gigantic pages when folio_list has entires.
Fixes: bfb41d6b2fe148 ("hugetlb: restructure pool allocations")
Signed-off-by: Usama Arif <usama.arif@bytedance.com>
---
mm/hugetlb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f3749fc125d4..b12f5fd295bb 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3397,7 +3397,8 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
}
/* list will be empty if hstate_is_gigantic */
- prep_and_add_allocated_folios(h, &folio_list);
+ if (!hstate_is_gigantic(h))
+ prep_and_add_allocated_folios(h, &folio_list);
if (i < h->max_huge_pages) {
char buf[32];
--
2.25.1
next reply other threads:[~2023-10-09 14:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 14:56 Usama Arif [this message]
2023-10-10 1:23 ` [PATCH] mm: hugetlb: Only prep and add allocated folios for non-gigantic pages Mike Kravetz
2023-10-10 17:01 ` [External] " Usama Arif
2023-10-10 21:30 ` Mike Kravetz
2023-10-10 21:31 ` Konrad Dybcio
2023-10-12 0:03 ` Nathan Chancellor
2023-10-12 14:53 ` Mike Kravetz
2023-10-13 0:12 ` Mike Kravetz
2023-10-14 0:04 ` Mike Kravetz
2023-10-18 20:54 ` Nick Desaulniers
2023-10-18 22:20 ` Mike Kravetz
2023-10-19 4:33 ` Sergey Senozhatsky
2023-10-19 14:20 ` Nathan Chancellor
2023-10-19 2:38 ` Mike Kravetz
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=20231009145605.2150897-1-usama.arif@bytedance.com \
--to=usama.arif@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=fam.zheng@bytedance.com \
--cc=liangma@liangbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=punit.agrawal@bytedance.com \
--cc=songmuchun@bytedance.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;
as well as URLs for NNTP newsgroup(s).