Skip to content

Commit f2ad878

Browse files
committed
syscall_steal: rename sys_call_table to fix compile error
sys_call_table is already declared in arch/x86/include/asm/syscall.h but of cource not exported by the kernel. before this commit, gcc complains as follows: /usr/src/linux-headers-6.1.0-16-common/arch/x86/include/asm/syscall.h:21:29: note: previous declaration of 'sys_call_table' with type 'long int (* const[])(const struct pt_regs *)' 21 | extern const sys_call_ptr_t sys_call_table[];
1 parent a60e84a commit f2ad878

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/syscall_steal.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
@@ -208,16 +208,16 @@ static void disable_write_protection(void)
208208

209209
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

@@ -228,19 +228,19 @@ static int __init syscall_steal_start(void)
228228

229229
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);

0 commit comments

Comments
 (0)