Skip to content

Commit

Permalink
LKM Issue for modpost: "kallsyms_lookup_name" for higher version of L…
Browse files Browse the repository at this point in the history
…INUX KERNEL resolved
  • Loading branch information
RST1996 committed Mar 27, 2022
1 parent 95808a0 commit 3834ef0
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions LKM/new_lkm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
#include <linux/semaphore.h>
#include <linux/syscalls.h>
#include <linux/kallsyms.h>
#include <linux/version.h>

#define FDPUT_FPUT 1
#define FDPUT_POS_UNLOCK 2
#define FMODE_ATOMIC_POS ((__force fmode_t)0x8000)

MODULE_DESCRIPTION("My kernel module");
MODULE_AUTHOR("Me");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,7,0)
#define KPROBE_LOOKUP 1
#include <linux/kprobes.h>
static struct kprobe kp = {
.symbol_name = "kallsyms_lookup_name"
};
#endif



MODULE_DESCRIPTION("Kernel Module to Augument the application logs");
MODULE_AUTHOR("CSE Dept. IIT KGP");
MODULE_LICENSE("GPL");

// static void **sys_call_table;
Expand Down Expand Up @@ -199,9 +210,18 @@ int set_addr_ro(void *ptr){
return 0;
}


static int init_function(void)
{


#ifdef KPROBE_LOOKUP
typedef unsigned long (*kallsyms_lookup_name_t)(const char *name);
kallsyms_lookup_name_t kallsyms_lookup_name;
register_kprobe(&kp);
kallsyms_lookup_name = (kallsyms_lookup_name_t) kp.addr;
unregister_kprobe(&kp);
#endif

sys_call_table_addr = kallsyms_lookup_name("sys_call_table");

set_addr_rw((void*)sys_call_table_addr);
Expand Down

0 comments on commit 3834ef0

Please sign in to comment.