From f49974968c9d19563a00c6a21f2219e834b40431 Mon Sep 17 00:00:00 2001 From: cisc7310x Date: Fri, 9 Feb 2018 19:07:53 -0500 Subject: [PATCH] reversed syscall for the 4.14 kernel --- 4.14.8/examples/syscall.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/4.14.8/examples/syscall.c b/4.14.8/examples/syscall.c index ccb901c..16222c5 100644 --- a/4.14.8/examples/syscall.c +++ b/4.14.8/examples/syscall.c @@ -25,7 +25,7 @@ #include #include -sys_call_ptr_t *sys_call_table_ptr; +unsigned long **sys_call_table; unsigned long original_cr0; /* @@ -87,18 +87,15 @@ asmlinkage int our_sys_open(const char *filename, int flags, int mode) return original_call(filename, flags, mode); } -static sys_call_ptr_t *aquire_sys_call_table(void) +static unsigned long **aquire_sys_call_table(void) { unsigned long int offset = PAGE_OFFSET; - /* unsigned long **sct; */ - sys_call_ptr_t *sct; + unsigned long **sct; while (offset < ULLONG_MAX) { - /* sct = (unsigned long **)offset; */ - sct = (sys_call_ptr_t *)offset; + sct = (unsigned long **)offset; - /* if (sct[__NR_close] == (unsigned long *) sys_close) */ - if (sct[__NR_close] == (sys_call_ptr_t) sys_close) + if (sct[__NR_close] == (unsigned long *) sys_close) return sct; offset += sizeof(void *); @@ -109,7 +106,7 @@ static sys_call_ptr_t *aquire_sys_call_table(void) static int __init syscall_start(void) { - if(!(sys_call_table_ptr = aquire_sys_call_table())) + if(!(sys_call_table = aquire_sys_call_table())) return -1; original_cr0 = read_cr0(); @@ -117,10 +114,10 @@ static int __init syscall_start(void) write_cr0(original_cr0 & ~0x00010000); /* keep track of the original open function */ - original_call = (void*)sys_call_table_ptr[__NR_open]; + original_call = (void*)sys_call_table[__NR_open]; /* use our open function instead */ - sys_call_table_ptr[__NR_open] = (sys_call_ptr_t)our_sys_open; + sys_call_table[__NR_open] = (unsigned long *)our_sys_open; write_cr0(original_cr0); @@ -131,14 +128,14 @@ static int __init syscall_start(void) static void __exit syscall_end(void) { - if(!sys_call_table_ptr) { + if(!sys_call_table) { return; } /* * Return the system call back to normal */ - if (sys_call_table_ptr[__NR_open] != (sys_call_ptr_t) our_sys_open) { + if (sys_call_table[__NR_open] != (unsigned long *)our_sys_open) { pr_alert("Somebody else also played with the "); pr_alert("open system call\n"); pr_alert("The system may be left in "); @@ -146,7 +143,7 @@ static void __exit syscall_end(void) } write_cr0(original_cr0 & ~0x00010000); - sys_call_table_ptr[__NR_open] = (sys_call_ptr_t)original_call; + sys_call_table[__NR_open] = (unsigned long *)original_call; write_cr0(original_cr0); msleep(2000);