Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kprobes: remove duplicated strong free_insn_page in x86 and s390

free_insn_page() in x86 and s390 is same with the common weak function in
kernel/kprobes.c. Plus, the comment "Recover page to RW mode before
releasing it" in x86 seems insensible to be there since resetting mapping
is done by common code in vfree() of module_memfree(). So drop these two
duplicated strong functions and related comment, then mark the common one
in kernel/kprobes.c strong.

Link: https://lkml.kernel.org/r/20210608065736.32656-1-song.bao.hua@hisilicon.com
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Qi Liu <liuqi115@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Barry Song and committed by
Linus Torvalds
66ce7514 86d1919a

+1 -13
-5
arch/s390/kernel/kprobes.c
··· 44 44 return page; 45 45 } 46 46 47 - void free_insn_page(void *page) 48 - { 49 - module_memfree(page); 50 - } 51 - 52 47 static void *alloc_s390_insn_page(void) 53 48 { 54 49 if (xchg(&insn_page_in_use, 1) == 1)
-6
arch/x86/kernel/kprobes/core.c
··· 422 422 return page; 423 423 } 424 424 425 - /* Recover page to RW mode before releasing it */ 426 - void free_insn_page(void *page) 427 - { 428 - module_memfree(page); 429 - } 430 - 431 425 /* Kprobe x86 instruction emulation - only regs->ip or IF flag modifiers */ 432 426 433 427 static void kprobe_emulate_ifmodifiers(struct kprobe *p, struct pt_regs *regs)
-1
include/linux/kprobes.h
··· 407 407 void dump_kprobe(struct kprobe *kp); 408 408 409 409 void *alloc_insn_page(void); 410 - void free_insn_page(void *page); 411 410 412 411 int kprobe_get_kallsym(unsigned int symnum, unsigned long *value, char *type, 413 412 char *sym);
+1 -1
kernel/kprobes.c
··· 106 106 return module_alloc(PAGE_SIZE); 107 107 } 108 108 109 - void __weak free_insn_page(void *page) 109 + static void free_insn_page(void *page) 110 110 { 111 111 module_memfree(page); 112 112 }