Skip to content

Commit 7f94878

Browse files
authored
Merge pull request #244 from keytouch/fix_syscall
Fix compilation due to syscall module name conflict
2 parents 3490cd7 + f2ad878 commit 7f94878

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

examples/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ obj-m += print_string.o
1616
obj-m += kbleds.o
1717
obj-m += sched.o
1818
obj-m += chardev2.o
19-
obj-m += syscall.o
19+
obj-m += syscall_steal.o
2020
obj-m += intrpt.o
2121
obj-m += cryptosha256.o
2222
obj-m += cryptosk.o

examples/syscall.c examples/syscall_steal.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* syscall.c
2+
* syscall_steal.c
33
*
44
* System call "stealing" sample.
55
*
@@ -61,7 +61,7 @@ module_param(sym, ulong, 0644);
6161

6262
#endif /* Version < v5.7 */
6363

64-
static unsigned long **sys_call_table;
64+
static unsigned long **sys_call_table_stolen;
6565

6666
/* UID we want to spy on - will be filled from the command line. */
6767
static uid_t uid = -1;
@@ -206,18 +206,18 @@ static void disable_write_protection(void)
206206
__write_cr0(cr0);
207207
}
208208

209-
static int __init syscall_start(void)
209+
static int __init syscall_steal_start(void)
210210
{
211-
if (!(sys_call_table = acquire_sys_call_table()))
211+
if (!(sys_call_table_stolen = acquire_sys_call_table()))
212212
return -1;
213213

214214
disable_write_protection();
215215

216216
/* keep track of the original open function */
217-
original_call = (void *)sys_call_table[__NR_openat];
217+
original_call = (void *)sys_call_table_stolen[__NR_openat];
218218

219219
/* use our openat function instead */
220-
sys_call_table[__NR_openat] = (unsigned long *)our_sys_openat;
220+
sys_call_table_stolen[__NR_openat] = (unsigned long *)our_sys_openat;
221221

222222
enable_write_protection();
223223

@@ -226,27 +226,27 @@ static int __init syscall_start(void)
226226
return 0;
227227
}
228228

229-
static void __exit syscall_end(void)
229+
static void __exit syscall_steal_end(void)
230230
{
231-
if (!sys_call_table)
231+
if (!sys_call_table_stolen)
232232
return;
233233

234234
/* Return the system call back to normal */
235-
if (sys_call_table[__NR_openat] != (unsigned long *)our_sys_openat) {
235+
if (sys_call_table_stolen[__NR_openat] != (unsigned long *)our_sys_openat) {
236236
pr_alert("Somebody else also played with the ");
237237
pr_alert("open system call\n");
238238
pr_alert("The system may be left in ");
239239
pr_alert("an unstable state.\n");
240240
}
241241

242242
disable_write_protection();
243-
sys_call_table[__NR_openat] = (unsigned long *)original_call;
243+
sys_call_table_stolen[__NR_openat] = (unsigned long *)original_call;
244244
enable_write_protection();
245245

246246
msleep(2000);
247247
}
248248

249-
module_init(syscall_start);
250-
module_exit(syscall_end);
249+
module_init(syscall_steal_start);
250+
module_exit(syscall_steal_end);
251251

252252
MODULE_LICENSE("GPL");

lkmpg.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ \section{System Calls}
14911491
ffffffff82000280 R x32_sys_call_table
14921492
ffffffff820013a0 R sys_call_table
14931493
ffffffff820023e0 R ia32_sys_call_table
1494-
$ sudo insmod syscall.ko sym=0xffffffff820013a0
1494+
$ sudo insmod syscall_steal.ko sym=0xffffffff820013a0
14951495
\end{verbatim}
14961496

14971497
Using the address from \verb|/boot/System.map|, be careful about \verb|KASLR| (Kernel Address Space Layout Randomization).

0 commit comments

Comments
 (0)