Skip to content

Commit c4678a0

Browse files
addisoncrumpOleksiiOleksenko
authored andcommitted
Add compat for kernel 5.7+
1 parent f1bb7b2 commit c4678a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

main.c

+15
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ int (*set_memory_nx)(unsigned long, int) = 0;
5050
#include <linux/set_memory.h>
5151
#endif
5252

53+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,7,0)
54+
#define KPROBE_LOOKUP 1
55+
#include <linux/kprobes.h>
56+
static struct kprobe kp = {
57+
.symbol_name = "kallsyms_lookup_name"
58+
};
59+
#endif
60+
5361
MODULE_LICENSE("GPL");
5462
MODULE_AUTHOR("Oleksii Oleksenko");
5563

@@ -369,6 +377,13 @@ static struct kobj_attribute
369377
static int __init nb_init(void) {
370378
pr_debug("Initializing x86-executor kernel module...\n");
371379
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
380+
#ifdef KPROBE_LOOKUP
381+
typedef unsigned long (*kallsyms_lookup_name_t)(const char *name);
382+
kallsyms_lookup_name_t kallsyms_lookup_name;
383+
register_kprobe(&kp);
384+
kallsyms_lookup_name = (kallsyms_lookup_name_t) kp.addr;
385+
unregister_kprobe(&kp);
386+
#endif
372387
set_memory_x = (void *) kallsyms_lookup_name("set_memory_x");
373388
set_memory_nx = (void *) kallsyms_lookup_name("set_memory_nx");
374389
#endif

0 commit comments

Comments
 (0)