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 <ptikhomi...@virtuozzo.com> --- 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) { -- 2.50.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel