From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,stable@vger.kernel.org,pjw@kernel.org,
muchun.song@linux.dev,glider@google.com,elver@google.com,dvyukov@google.com,
aou@eecs.berkeley.edu,alex@ghiti.fr,liuyun01@kylinos.cn,
akpm@linux-foundation.org
Subject: + kfence-clear-the-pool-pointer-before-freeing-pages.patch added to mm-new branch
Date: Thu, 29 Oct 2026 18:30:15 -0700 [thread overview]
Message-ID: <20261030013016.345DF1F000C1@smtp.kernel.org> (raw)
The patch titled
Subject: kfence: clear the pool pointer before freeing pages
has been added to the -mm mm-new branch. Its filename is
kfence-clear-the-pool-pointer-before-freeing-pages.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kfence-clear-the-pool-pointer-before-freeing-pages.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Jackie Liu <liuyun01@kylinos.cn>
Subject: kfence: clear the pool pointer before freeing pages
Date: Thu, 29 Oct 2026 10:57:42 +0800
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.
Link: https://lore.kernel.org/2fab8aaa82ab2004e706fd7ec8dac20427976457.1793242457.git.liuyun01@kylinos.cn
Fixes: b33f778bba5e ("kfence: alloc kfence_pool after system startup")
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: AlexandreGhiti <alex@ghiti.fr>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: <stable@vger.kernel.org>
---
mm/kfence/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/mm/kfence/core.c~kfence-clear-the-pool-pointer-before-freeing-pages
+++ a/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;
}
_
Patches currently in -mm which might be from liuyun01@kylinos.cn are
kfence-fix-pool-cleanup-on-metadata-allocation-failure.patch
kfence-clear-the-pool-pointer-before-freeing-pages.patch
riscv-keep-booting-if-kfence-pool-reservation-fails.patch
reply other threads:[~2026-10-30 1:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261030013016.345DF1F000C1@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=liuyun01@kylinos.cn \
--cc=mm-commits@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=pjw@kernel.org \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.