[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230328095807.7014-3-songmuchun@bytedance.com>
Date: Tue, 28 Mar 2023 17:58:03 +0800
From: Muchun Song <songmuchun@...edance.com>
To: glider@...gle.com, elver@...gle.com, dvyukov@...gle.com,
akpm@...ux-foundation.org, jannh@...gle.com, sjpark@...zon.de,
muchun.song@...ux.dev
Cc: kasan-dev@...glegroups.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Muchun Song <songmuchun@...edance.com>
Subject: [PATCH 2/6] mm: kfence: check kfence pool size at building time
Check kfence pool size at building time to expose problem ASAP.
Signed-off-by: Muchun Song <songmuchun@...edance.com>
---
mm/kfence/core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index de62a84d4830..6781af1dfa66 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -841,10 +841,9 @@ static int kfence_init_late(void)
return -ENOMEM;
__kfence_pool = page_to_virt(pages);
#else
- if (nr_pages > MAX_ORDER_NR_PAGES) {
- pr_warn("KFENCE_NUM_OBJECTS too large for buddy allocator\n");
- return -EINVAL;
- }
+ BUILD_BUG_ON_MSG(get_order(KFENCE_POOL_SIZE) > MAX_ORDER,
+ "CONFIG_KFENCE_NUM_OBJECTS is too large for buddy allocator");
+
__kfence_pool = alloc_pages_exact(KFENCE_POOL_SIZE, GFP_KERNEL);
if (!__kfence_pool)
return -ENOMEM;
--
2.11.0
Powered by blists - more mailing lists