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[];
This commit is contained in:
keytouch 2023-12-22 11:46:46 +08:00
parent a60e84a060
commit f2ad878e9b

View File

@ -61,7 +61,7 @@ module_param(sym, ulong, 0644);
#endif /* Version < v5.7 */ #endif /* Version < v5.7 */
static unsigned long **sys_call_table; static unsigned long **sys_call_table_stolen;
/* UID we want to spy on - will be filled from the command line. */ /* UID we want to spy on - will be filled from the command line. */
static uid_t uid = -1; static uid_t uid = -1;
@ -208,16 +208,16 @@ static void disable_write_protection(void)
static int __init syscall_steal_start(void) static int __init syscall_steal_start(void)
{ {
if (!(sys_call_table = acquire_sys_call_table())) if (!(sys_call_table_stolen = acquire_sys_call_table()))
return -1; return -1;
disable_write_protection(); disable_write_protection();
/* keep track of the original open function */ /* keep track of the original open function */
original_call = (void *)sys_call_table[__NR_openat]; original_call = (void *)sys_call_table_stolen[__NR_openat];
/* use our openat function instead */ /* use our openat function instead */
sys_call_table[__NR_openat] = (unsigned long *)our_sys_openat; sys_call_table_stolen[__NR_openat] = (unsigned long *)our_sys_openat;
enable_write_protection(); enable_write_protection();
@ -228,11 +228,11 @@ static int __init syscall_steal_start(void)
static void __exit syscall_steal_end(void) static void __exit syscall_steal_end(void)
{ {
if (!sys_call_table) if (!sys_call_table_stolen)
return; return;
/* Return the system call back to normal */ /* Return the system call back to normal */
if (sys_call_table[__NR_openat] != (unsigned long *)our_sys_openat) { if (sys_call_table_stolen[__NR_openat] != (unsigned long *)our_sys_openat) {
pr_alert("Somebody else also played with the "); pr_alert("Somebody else also played with the ");
pr_alert("open system call\n"); pr_alert("open system call\n");
pr_alert("The system may be left in "); pr_alert("The system may be left in ");
@ -240,7 +240,7 @@ static void __exit syscall_steal_end(void)
} }
disable_write_protection(); disable_write_protection();
sys_call_table[__NR_openat] = (unsigned long *)original_call; sys_call_table_stolen[__NR_openat] = (unsigned long *)original_call;
enable_write_protection(); enable_write_protection();
msleep(2000); msleep(2000);