* [PATCH v2 0/3] kfence: fix pool allocation failure handling
@ 2026-10-29 2:57 ` Jackie Liu
0 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-29 2:57 UTC (permalink / raw)
To: glider
Cc: dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm, kasan-dev,
muchun.song, liu.yun
From: Jackie Liu <liuyun01@kylinos.cn>
Fix the cleanup address and page reuse window in failed late KFENCE
initialization. Also let RISC-V boot if the early pool reservation fails.
Patch 2 depends on patch 1. Patch 3 can be applied independently.
Changes in v2:
- Add Marco Elver's Reviewed-by to patches 1 and 2; their code is unchanged.
- Drop the unused asm/kfence.h include from patch 3. Sashiko reported that
its unconditional inclusion breaks RV32 and NOMMU builds.
- Credit Sashiko and kernel test robot with Reported-by and Closes tags
in patch 3.
v1: https://lore.kernel.org/all/cover.1793017073.git.liuyun01@kylinos.cn/
Reports:
https://sashiko.dev/#/patchset/cover.1793017073.git.liuyun01@kylinos.cn?part=3
https://lore.kernel.org/all/sashiko-outbox-186543@kernel.org/
https://lore.kernel.org/oe-kbuild-all/202610290904.wbrEL97y-lkp@intel.com/
Validation on AArch64 Linux with Clang 17.0.6 and GNU ld 2.40:
- RV32 and NOMMU: reproduced v1 failures; v2 init.o builds successfully.
- RV64 defconfig with CONFIG_KFENCE=y: init.o, mm/kfence/core.o, and the
full Image build pass without warnings.
The existing NOMMU warning in include/asm-generic/io.h is identical to
that from the unpatched base. No boot or failure-injection tests were run.
All three patches pass checkpatch.pl --strict and git diff --check.
OpenAI Codex assisted with review, adaptation, wording, and validation.
Jackie Liu (3):
kfence: fix pool cleanup on metadata allocation failure
kfence: clear the pool pointer before freeing pages
riscv: keep booting if KFENCE pool reservation fails
arch/riscv/include/asm/kfence.h | 4 +++-
arch/riscv/mm/init.c | 18 ++++++++++++++----
mm/kfence/core.c | 6 ++++--
3 files changed, 21 insertions(+), 7 deletions(-)
base-commit: 7be4bc52fd9e0e55dc9a2e0232b89427d2c4b614
--
2.56.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 1/3] kfence: fix pool cleanup on metadata allocation failure
2026-10-29 2:57 ` Jackie Liu
@ 2026-10-29 2:57 ` Jackie Liu
-1 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-29 2:57 UTC (permalink / raw)
To: glider
Cc: dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm, kasan-dev,
muchun.song, liu.yun
From: Jackie Liu <liuyun01@kylinos.cn>
kfence_init_late() saves __kfence_pool in addr before allocating the pool,
so addr is still NULL if metadata allocation fails. The error path then
tries to free pages using that address.
Set addr after pool allocation so cleanup frees the allocated pool.
Fixes: cabdf74e6b31 ("mm: kfence: allocate kfence_metadata at runtime")
Cc: stable@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Reviewed-by: Marco Elver <elver@google.com>
---
mm/kfence/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 90925c646c4c..6e3d01bccdf1 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -999,7 +999,7 @@ static int kfence_init_late(void)
{
const unsigned long nr_pages_pool = KFENCE_POOL_SIZE / PAGE_SIZE;
const unsigned long nr_pages_meta = KFENCE_METADATA_SIZE / PAGE_SIZE;
- unsigned long addr = (unsigned long)__kfence_pool;
+ unsigned long addr;
unsigned long free_size = KFENCE_POOL_SIZE;
int err = -ENOMEM;
@@ -1032,6 +1032,7 @@ static int kfence_init_late(void)
GFP_KERNEL | __GFP_SKIP_KASAN);
#endif
+ addr = (unsigned long)__kfence_pool;
if (!kfence_metadata_init)
goto free_pool;
--
2.56.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 1/3] kfence: fix pool cleanup on metadata allocation failure
@ 2026-10-29 2:57 ` Jackie Liu
0 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-29 2:57 UTC (permalink / raw)
To: glider
Cc: dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm, kasan-dev,
muchun.song, liu.yun
From: Jackie Liu <liuyun01@kylinos.cn>
kfence_init_late() saves __kfence_pool in addr before allocating the pool,
so addr is still NULL if metadata allocation fails. The error path then
tries to free pages using that address.
Set addr after pool allocation so cleanup frees the allocated pool.
Fixes: cabdf74e6b31 ("mm: kfence: allocate kfence_metadata at runtime")
Cc: stable@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Reviewed-by: Marco Elver <elver@google.com>
---
mm/kfence/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 90925c646c4c..6e3d01bccdf1 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -999,7 +999,7 @@ static int kfence_init_late(void)
{
const unsigned long nr_pages_pool = KFENCE_POOL_SIZE / PAGE_SIZE;
const unsigned long nr_pages_meta = KFENCE_METADATA_SIZE / PAGE_SIZE;
- unsigned long addr = (unsigned long)__kfence_pool;
+ unsigned long addr;
unsigned long free_size = KFENCE_POOL_SIZE;
int err = -ENOMEM;
@@ -1032,6 +1032,7 @@ static int kfence_init_late(void)
GFP_KERNEL | __GFP_SKIP_KASAN);
#endif
+ addr = (unsigned long)__kfence_pool;
if (!kfence_metadata_init)
goto free_pool;
--
2.56.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 2/3] kfence: clear the pool pointer before freeing pages
2026-10-29 2:57 ` Jackie Liu
@ 2026-10-29 2:57 ` Jackie Liu
-1 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-29 2:57 UTC (permalink / raw)
To: glider
Cc: dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm, kasan-dev,
muchun.song, liu.yun
From: Jackie Liu <liuyun01@kylinos.cn>
Late initialization frees a failed pool before clearing __kfence_pool.
Slab allocations can reuse those pages in between and be mistaken for
KFENCE objects by is_kfence_address(), even though KFENCE is not enabled.
Clear __kfence_pool before freeing the pages, and use the saved address
for cleanup.
Fixes: b33f778bba5e ("kfence: alloc kfence_pool after system startup")
Cc: stable@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Reviewed-by: Marco Elver <elver@google.com>
---
mm/kfence/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 6e3d01bccdf1..434df6cef7f2 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -1052,16 +1052,17 @@ static int kfence_init_late(void)
free_contig_range(page_to_pfn(virt_to_page((void *)kfence_metadata_init)),
nr_pages_meta);
free_pool:
+ WRITE_ONCE(__kfence_pool, NULL);
free_contig_range(page_to_pfn(virt_to_page((void *)addr)),
free_size / PAGE_SIZE);
#else
free_pages_exact((void *)kfence_metadata_init, KFENCE_METADATA_SIZE);
free_pool:
+ WRITE_ONCE(__kfence_pool, NULL);
free_pages_exact((void *)addr, free_size);
#endif
kfence_metadata_init = NULL;
- __kfence_pool = NULL;
return err;
}
--
2.56.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 2/3] kfence: clear the pool pointer before freeing pages
@ 2026-10-29 2:57 ` Jackie Liu
0 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-29 2:57 UTC (permalink / raw)
To: glider
Cc: dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm, kasan-dev,
muchun.song, liu.yun
From: Jackie Liu <liuyun01@kylinos.cn>
Late initialization frees a failed pool before clearing __kfence_pool.
Slab allocations can reuse those pages in between and be mistaken for
KFENCE objects by is_kfence_address(), even though KFENCE is not enabled.
Clear __kfence_pool before freeing the pages, and use the saved address
for cleanup.
Fixes: b33f778bba5e ("kfence: alloc kfence_pool after system startup")
Cc: stable@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Reviewed-by: Marco Elver <elver@google.com>
---
mm/kfence/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 6e3d01bccdf1..434df6cef7f2 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -1052,16 +1052,17 @@ static int kfence_init_late(void)
free_contig_range(page_to_pfn(virt_to_page((void *)kfence_metadata_init)),
nr_pages_meta);
free_pool:
+ WRITE_ONCE(__kfence_pool, NULL);
free_contig_range(page_to_pfn(virt_to_page((void *)addr)),
free_size / PAGE_SIZE);
#else
free_pages_exact((void *)kfence_metadata_init, KFENCE_METADATA_SIZE);
free_pool:
+ WRITE_ONCE(__kfence_pool, NULL);
free_pages_exact((void *)addr, free_size);
#endif
kfence_metadata_init = NULL;
- __kfence_pool = NULL;
return err;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 3/3] riscv: keep booting if KFENCE pool reservation fails
2026-10-29 2:57 ` Jackie Liu
@ 2026-10-29 2:57 ` Jackie Liu
-1 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-29 2:57 UTC (permalink / raw)
To: glider
Cc: dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm, kasan-dev,
muchun.song, liu.yun
From: Jackie Liu <liuyun01@kylinos.cn>
A failed KFENCE pool reservation hits BUG_ON() and stops boot. Continue
building the linear map and disable KFENCE if the reservation fails.
Reject later pool initialization as well, since a replacement pool may
have huge-page mappings that kfence_protect_page() cannot handle.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/cover.1793017073.git.liuyun01@kylinos.cn?part=3
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202610290904.wbrEL97y-lkp@intel.com/
Fixes: 25abe0db9243 ("riscv: Fix kfence now that the linear mapping can be backed by PUD/P4D/PGD")
Cc: stable@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
arch/riscv/include/asm/kfence.h | 4 +++-
arch/riscv/mm/init.c | 18 ++++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/include/asm/kfence.h b/arch/riscv/include/asm/kfence.h
index 29cb3a6ee113..57e57426a7d6 100644
--- a/arch/riscv/include/asm/kfence.h
+++ b/arch/riscv/include/asm/kfence.h
@@ -9,9 +9,11 @@
#include <asm/cacheflush.h>
#include <asm/pgtable.h>
+extern bool kfence_disabled;
+
static inline bool arch_kfence_init_pool(void)
{
- return true;
+ return !kfence_disabled;
}
static inline bool kfence_protect_page(unsigned long addr, bool protect)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index fb37b0b67efe..d21be990346c 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -44,6 +44,10 @@ DECLARE_BITMAP(new_valid_map_cpus, NR_CPUS);
struct kernel_mapping kernel_map __ro_after_init;
EXPORT_SYMBOL(kernel_map);
+#ifdef CONFIG_KFENCE
+bool kfence_disabled __ro_after_init;
+#endif
+
#ifdef CONFIG_64BIT
u64 satp_mode __ro_after_init = SATP_MODE_57;
#else
@@ -1229,10 +1233,13 @@ static void __init create_linear_mapping_page_table(void)
* for this region.
*/
kfence_pool = memblock_phys_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
- BUG_ON(!kfence_pool);
-
- memblock_mark_nomap(kfence_pool, KFENCE_POOL_SIZE);
- __kfence_pool = __va(kfence_pool);
+ if (kfence_pool) {
+ memblock_mark_nomap(kfence_pool, KFENCE_POOL_SIZE);
+ __kfence_pool = __va(kfence_pool);
+ } else {
+ pr_err("failed to allocate kfence pool\n");
+ kfence_disabled = true;
+ }
#endif
/* Map all memory banks in the linear mapping */
@@ -1253,6 +1260,9 @@ static void __init create_linear_mapping_page_table(void)
#endif
#ifdef CONFIG_KFENCE
+ if (!kfence_pool)
+ return;
+
create_linear_mapping_range(kfence_pool, kfence_pool + KFENCE_POOL_SIZE, PAGE_SIZE, NULL);
memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE);
--
2.56.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 3/3] riscv: keep booting if KFENCE pool reservation fails
@ 2026-10-29 2:57 ` Jackie Liu
0 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-29 2:57 UTC (permalink / raw)
To: glider
Cc: dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm, kasan-dev,
muchun.song, liu.yun
From: Jackie Liu <liuyun01@kylinos.cn>
A failed KFENCE pool reservation hits BUG_ON() and stops boot. Continue
building the linear map and disable KFENCE if the reservation fails.
Reject later pool initialization as well, since a replacement pool may
have huge-page mappings that kfence_protect_page() cannot handle.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/cover.1793017073.git.liuyun01@kylinos.cn?part=3
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202610290904.wbrEL97y-lkp@intel.com/
Fixes: 25abe0db9243 ("riscv: Fix kfence now that the linear mapping can be backed by PUD/P4D/PGD")
Cc: stable@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
arch/riscv/include/asm/kfence.h | 4 +++-
arch/riscv/mm/init.c | 18 ++++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/include/asm/kfence.h b/arch/riscv/include/asm/kfence.h
index 29cb3a6ee113..57e57426a7d6 100644
--- a/arch/riscv/include/asm/kfence.h
+++ b/arch/riscv/include/asm/kfence.h
@@ -9,9 +9,11 @@
#include <asm/cacheflush.h>
#include <asm/pgtable.h>
+extern bool kfence_disabled;
+
static inline bool arch_kfence_init_pool(void)
{
- return true;
+ return !kfence_disabled;
}
static inline bool kfence_protect_page(unsigned long addr, bool protect)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index fb37b0b67efe..d21be990346c 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -44,6 +44,10 @@ DECLARE_BITMAP(new_valid_map_cpus, NR_CPUS);
struct kernel_mapping kernel_map __ro_after_init;
EXPORT_SYMBOL(kernel_map);
+#ifdef CONFIG_KFENCE
+bool kfence_disabled __ro_after_init;
+#endif
+
#ifdef CONFIG_64BIT
u64 satp_mode __ro_after_init = SATP_MODE_57;
#else
@@ -1229,10 +1233,13 @@ static void __init create_linear_mapping_page_table(void)
* for this region.
*/
kfence_pool = memblock_phys_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
- BUG_ON(!kfence_pool);
-
- memblock_mark_nomap(kfence_pool, KFENCE_POOL_SIZE);
- __kfence_pool = __va(kfence_pool);
+ if (kfence_pool) {
+ memblock_mark_nomap(kfence_pool, KFENCE_POOL_SIZE);
+ __kfence_pool = __va(kfence_pool);
+ } else {
+ pr_err("failed to allocate kfence pool\n");
+ kfence_disabled = true;
+ }
#endif
/* Map all memory banks in the linear mapping */
@@ -1253,6 +1260,9 @@ static void __init create_linear_mapping_page_table(void)
#endif
#ifdef CONFIG_KFENCE
+ if (!kfence_pool)
+ return;
+
create_linear_mapping_range(kfence_pool, kfence_pool + KFENCE_POOL_SIZE, PAGE_SIZE, NULL);
memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE);
--
2.56.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 3/3] riscv: keep booting if KFENCE pool reservation fails
2026-10-29 2:57 ` Jackie Liu
(?)
@ 2026-10-30 2:58 ` sashiko-bot
-1 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-10-30 2:58 UTC (permalink / raw)
To: Jackie Liu, glider
Cc: dvyukov, elver, pjw, alex, aou, linux-mm, kasan-dev, muchun.song
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] riscv: kfence: incomplete replacement pool rejection and fallback memblock leak
--
commit 3fb224ed3ecf516e32ff76314492cf99262a5a4f
Author: Jackie Liu <liuyun01@kylinos.cn>
riscv: keep booting if KFENCE pool reservation fails
This commit avoids hitting BUG_ON() during linear mapping setup when the
early KFENCE pool reservation fails by tracking the failure in
kfence_disabled and returning !kfence_disabled from arch_kfence_init_pool().
> diff --git a/arch/riscv/include/asm/kfence.h b/arch/riscv/include/asm/kfence.h
> index 29cb3a6ee113d..57e57426a7d60 100644
> --- a/arch/riscv/include/asm/kfence.h
> +++ b/arch/riscv/include/asm/kfence.h
> @@ -9,9 +9,11 @@
> #include <asm/cacheflush.h>
> #include <asm/pgtable.h>
>
> +extern bool kfence_disabled;
> +
> static inline bool arch_kfence_init_pool(void)
> {
> - return true;
> + return !kfence_disabled;
> }
>
> static inline bool kfence_protect_page(unsigned long addr, bool protect)
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index fb37b0b67efec..d21be990346c6 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -44,6 +44,10 @@ DECLARE_BITMAP(new_valid_map_cpus, NR_CPUS);
> struct kernel_mapping kernel_map __ro_after_init;
> EXPORT_SYMBOL(kernel_map);
>
> +#ifdef CONFIG_KFENCE
> +bool kfence_disabled __ro_after_init;
> +#endif
> +
> #ifdef CONFIG_64BIT
> u64 satp_mode __ro_after_init = SATP_MODE_57;
> #else
> @@ -1229,10 +1233,13 @@ static void __init create_linear_mapping_page_table(void)
> * for this region.
> */
> kfence_pool = memblock_phys_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
> - BUG_ON(!kfence_pool);
> -
> - memblock_mark_nomap(kfence_pool, KFENCE_POOL_SIZE);
> - __kfence_pool = __va(kfence_pool);
> + if (kfence_pool) {
> + memblock_mark_nomap(kfence_pool, KFENCE_POOL_SIZE);
> + __kfence_pool = __va(kfence_pool);
> + } else {
> + pr_err("failed to allocate kfence pool\n");
> + kfence_disabled = true;
> + }
[Severity: High]
Does setting kfence_disabled without clearing kfence_sample_interval still
allow a fallback memblock allocation and a late hugepage-backed replacement
pool?
In mm/kfence/core.c:kfence_alloc_pool_and_metadata():
if (!kfence_sample_interval)
return;
/*
* If the pool has already been initialized by arch, there is no need to
* re-allocate the memory pool.
*/
if (!__kfence_pool)
__kfence_pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
...
kfence_metadata_init = memblock_alloc(KFENCE_METADATA_SIZE, PAGE_SIZE);
if (!kfence_metadata_init) {
pr_err("failed to allocate metadata\n");
memblock_free(__kfence_pool, KFENCE_POOL_SIZE);
__kfence_pool = NULL;
}
There look to be two issues with relying solely on kfence_disabled here:
First, when memblock_phys_alloc() fails in create_linear_mapping_page_table(),
__kfence_pool remains NULL while kfence_sample_interval is still non-zero.
Later in mm_core_init(), kfence_alloc_pool_and_metadata() will allocate a
fallback __kfence_pool and kfence_metadata_init from memblock. When
kfence_init() -> kfence_init_pool_early() subsequently runs and sees
arch_kfence_init_pool() return false, it calls memblock_free() on both
allocations after kmem_cache_init() has already set slab_is_available().
When CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, memblock_free() ->
memblock_phys_free() -> __free_reserved_area() triggers a warning because
deferred struct page initialization has not yet run, leaking both
__kfence_pool and kfence_metadata_init.
Second, if memblock_phys_alloc() succeeds in
create_linear_mapping_page_table() (leaving kfence_disabled false), but the
subsequent kfence_metadata_init allocation in kfence_alloc_pool_and_metadata()
fails, the early PTE-mapped __kfence_pool is freed and reset to NULL while
kfence_disabled remains false. If KFENCE is later enabled at runtime via
sample_interval, kfence_enable_late() -> kfence_init_late() will allocate a
replacement pool from the linear map (which may be backed by PMD/PUD/P4D/PGD
hugepages), arch_kfence_init_pool() will return true, and
kfence_protect_page() -> virt_to_kpte() will walk the page tables assuming
PTE mappings, which can corrupt memory or fault.
Would setting kfence_sample_interval = 0 on allocation failure in
create_linear_mapping_page_table() and checking whether the address falls
within the early PTE-mapped pool range (or disabling late initialization in
arch_kfence_init_pool()) avoid both paths?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1793242457.git.liuyun01@kylinos.cn?part=3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/3] kfence: fix pool allocation failure handling
2026-10-29 2:57 ` Jackie Liu
@ 2026-10-30 1:26 ` Andrew Morton
-1 siblings, 0 replies; 15+ messages in thread
From: Andrew Morton @ 2026-10-30 1:26 UTC (permalink / raw)
To: Jackie Liu
Cc: glider, dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm,
kasan-dev, muchun.song
On Thu, 29 Oct 2026 10:57:40 +0800 Jackie Liu <liu.yun@linux.dev> wrote:
> Fix the cleanup address and page reuse window in failed late KFENCE
> initialization. Also let RISC-V boot if the early pool reservation fails.
>
> Patch 2 depends on patch 1. Patch 3 can be applied independently.
Thanks.
We're all horridly busy with bugfixes at present and the first thing
recipients think when presented with yet another is "why should I look
at this".
So it really helps to start out with a succinct and punchy sentence
which explains that thing.
LLM suggested to me
: KFENCE initialization failures can cause kernel crashes or memory
: corruption, while a RISC-V failure can prevent the system from booting.
: These fixes make the failure paths safe and allow systems to continue
: running with KFENCE disabled.
How does that sound?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/3] kfence: fix pool allocation failure handling
@ 2026-10-30 1:26 ` Andrew Morton
0 siblings, 0 replies; 15+ messages in thread
From: Andrew Morton @ 2026-10-30 1:26 UTC (permalink / raw)
To: Jackie Liu
Cc: glider, dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm,
kasan-dev, muchun.song
On Thu, 29 Oct 2026 10:57:40 +0800 Jackie Liu <liu.yun@linux.dev> wrote:
> Fix the cleanup address and page reuse window in failed late KFENCE
> initialization. Also let RISC-V boot if the early pool reservation fails.
>
> Patch 2 depends on patch 1. Patch 3 can be applied independently.
Thanks.
We're all horridly busy with bugfixes at present and the first thing
recipients think when presented with yet another is "why should I look
at this".
So it really helps to start out with a succinct and punchy sentence
which explains that thing.
LLM suggested to me
: KFENCE initialization failures can cause kernel crashes or memory
: corruption, while a RISC-V failure can prevent the system from booting.
: These fixes make the failure paths safe and allow systems to continue
: running with KFENCE disabled.
How does that sound?
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/3] kfence: fix pool allocation failure handling
2026-10-30 1:26 ` Andrew Morton
@ 2026-10-30 5:55 ` Jackie Liu
-1 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-30 5:55 UTC (permalink / raw)
To: Andrew Morton
Cc: glider, dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm,
kasan-dev, muchun.song
2026年10月30日 09:26, "Andrew Morton" <akpm@linux-foundation.org mailto:akpm@linux-foundation.org?to=%22Andrew%20Morton%22%20%3Cakpm%40linux-foundation.org%3E > 写到:
>
> On Thu, 29 Oct 2026 10:57:40 +0800 Jackie Liu <liu.yun@linux.dev> wrote:
>
> >
> > Fix the cleanup address and page reuse window in failed late KFENCE
> > initialization. Also let RISC-V boot if the early pool reservation fails.
> >
> > Patch 2 depends on patch 1. Patch 3 can be applied independently.
> >
> Thanks.
>
> We're all horridly busy with bugfixes at present and the first thing
> recipients think when presented with yet another is "why should I look
> at this".
>
> So it really helps to start out with a succinct and punchy sentence
> which explains that thing.
>
> LLM suggested to me
>
> : KFENCE initialization failures can cause kernel crashes or memory
> : corruption, while a RISC-V failure can prevent the system from booting.
> : These fixes make the failure paths safe and allow systems to continue
> : running with KFENCE disabled.
>
> How does that sound?
Hi Andrew,
Thanks for the suggestion. That wording sounds good to me. It makes
the impact of these bugs much clearer, and I'll keep this in mind
when writing future patch descriptions.
Also, Sashiko has reported an issue with patch 3/3.
Could you please apply only the first two patches and drop patch 3/3
for now? I'll address the reported issue and resend the third patch
separately once it's fixed.
Thanks,
Jackie
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/3] kfence: fix pool allocation failure handling
@ 2026-10-30 5:55 ` Jackie Liu
0 siblings, 0 replies; 15+ messages in thread
From: Jackie Liu @ 2026-10-30 5:55 UTC (permalink / raw)
To: Andrew Morton
Cc: glider, dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm,
kasan-dev, muchun.song
2026年10月30日 09:26, "Andrew Morton" <akpm@linux-foundation.org mailto:akpm@linux-foundation.org?to=%22Andrew%20Morton%22%20%3Cakpm%40linux-foundation.org%3E > 写到:
>
> On Thu, 29 Oct 2026 10:57:40 +0800 Jackie Liu <liu.yun@linux.dev> wrote:
>
> >
> > Fix the cleanup address and page reuse window in failed late KFENCE
> > initialization. Also let RISC-V boot if the early pool reservation fails.
> >
> > Patch 2 depends on patch 1. Patch 3 can be applied independently.
> >
> Thanks.
>
> We're all horridly busy with bugfixes at present and the first thing
> recipients think when presented with yet another is "why should I look
> at this".
>
> So it really helps to start out with a succinct and punchy sentence
> which explains that thing.
>
> LLM suggested to me
>
> : KFENCE initialization failures can cause kernel crashes or memory
> : corruption, while a RISC-V failure can prevent the system from booting.
> : These fixes make the failure paths safe and allow systems to continue
> : running with KFENCE disabled.
>
> How does that sound?
Hi Andrew,
Thanks for the suggestion. That wording sounds good to me. It makes
the impact of these bugs much clearer, and I'll keep this in mind
when writing future patch descriptions.
Also, Sashiko has reported an issue with patch 3/3.
Could you please apply only the first two patches and drop patch 3/3
for now? I'll address the reported issue and resend the third patch
separately once it's fixed.
Thanks,
Jackie
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/3] kfence: fix pool allocation failure handling
2026-10-30 5:55 ` Jackie Liu
@ 2026-10-30 6:55 ` Andrew Morton
-1 siblings, 0 replies; 15+ messages in thread
From: Andrew Morton @ 2026-10-30 6:55 UTC (permalink / raw)
To: Jackie Liu
Cc: glider, dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm,
kasan-dev, muchun.song
On Fri, 30 Oct 2026 05:55:21 +0000 "Jackie Liu" <liu.yun@linux.dev> wrote:
>
> Also, Sashiko has reported an issue with patch 3/3.
thanks, I missed that.
> Could you please apply only the first two patches and drop patch 3/3
> for now? I'll address the reported issue and resend the third patch
> separately once it's fixed.
Sure.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/3] kfence: fix pool allocation failure handling
@ 2026-10-30 6:55 ` Andrew Morton
0 siblings, 0 replies; 15+ messages in thread
From: Andrew Morton @ 2026-10-30 6:55 UTC (permalink / raw)
To: Jackie Liu
Cc: glider, dvyukov, elver, pjw, alex, aou, linux-riscv, linux-mm,
kasan-dev, muchun.song
On Fri, 30 Oct 2026 05:55:21 +0000 "Jackie Liu" <liu.yun@linux.dev> wrote:
>
> Also, Sashiko has reported an issue with patch 3/3.
thanks, I missed that.
> Could you please apply only the first two patches and drop patch 3/3
> for now? I'll address the reported issue and resend the third patch
> separately once it's fixed.
Sure.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 15+ messages in thread