[Devel] [PATCH RHEL9 COMMIT] readykernel: export symbols to be able to livepatch kfree/kvfree replacement
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 22 18:51:05 MSK 2025
The commit is pushed to "branch-rh9-5.14.0-427.77.1.vz9.86.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.77.1.vz9.86.5
------>
commit 1204de9652226f879b27c733508e19baab74a2ac
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date: Tue Aug 12 16:01:54 2025 +0800
readykernel: export symbols to be able to livepatch kfree/kvfree replacement
We can't just use normal readykernel patching for kfree/kvfree, as the
counterpart with kmalloc/kvmalloc might've allocated non-continious
memory and that memory should not be freed with kfree even after
readykernel patch was unloaded.
So the idea is to make the kfree/kvfree change permanent. For that we
need to export: kallsyms_lookup_name, set_memory_ro, set_memory_rw,
find_module and copy_to_kernel_nofault. So let's export them to be able
to do this trick in future.
See prototype implementation here:
https://bitbucket.org/openvz/kpatch/branch/vz9-fuse_kio_pcs-kvfree-prototype
85fc534 ("fuse_kio_pcs: Permanently replace kfree with kvfree in pcs_umem_release")
874c2a8 ("Add kpatch_replace_call helper to manualy replace kernel function calls")
https://virtuozzo.atlassian.net/browse/RK-536
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Feature: ReadyKernel
---
arch/arm/mm/pageattr.c | 2 ++
kernel/kallsyms.c | 1 +
kernel/module.c | 1 +
mm/maccess.c | 1 +
4 files changed, 5 insertions(+)
diff --git a/arch/arm/mm/pageattr.c b/arch/arm/mm/pageattr.c
index 9790ae3a8c687..ff650f366dec3 100644
--- a/arch/arm/mm/pageattr.c
+++ b/arch/arm/mm/pageattr.c
@@ -66,6 +66,7 @@ int set_memory_ro(unsigned long addr, int numpages)
__pgprot(L_PTE_RDONLY),
__pgprot(0));
}
+EXPORT_SYMBOL_GPL(set_memory_ro);
int set_memory_rw(unsigned long addr, int numpages)
{
@@ -73,6 +74,7 @@ int set_memory_rw(unsigned long addr, int numpages)
__pgprot(0),
__pgprot(L_PTE_RDONLY));
}
+EXPORT_SYMBOL_GPL(set_memory_rw);
int set_memory_nx(unsigned long addr, int numpages)
{
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index c8b43ad04f47f..a0ca1524b3b5d 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -188,6 +188,7 @@ unsigned long kallsyms_lookup_name(const char *name)
}
return module_kallsyms_lookup_name(name);
}
+EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
/*
* Iterate over all symbols in vmlinux. For symbols from modules use
diff --git a/kernel/module.c b/kernel/module.c
index 827fcd008de0a..c4a8eb203df4e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -581,6 +581,7 @@ struct module *find_module(const char *name)
{
return find_module_all(name, strlen(name), false);
}
+EXPORT_SYMBOL_GPL(find_module);
#ifdef CONFIG_SMP
diff --git a/mm/maccess.c b/mm/maccess.c
index 518a25667323e..ec180d956547f 100644
--- a/mm/maccess.c
+++ b/mm/maccess.c
@@ -76,6 +76,7 @@ long copy_to_kernel_nofault(void *dst, const void *src, size_t size)
pagefault_enable();
return -EFAULT;
}
+EXPORT_SYMBOL_GPL(copy_to_kernel_nofault);
long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
{
More information about the Devel
mailing list