NAME dyn_syscall_reg, hijack_syscall - Register a system call SYNOPSIS #include int dyn_syscall_reg(const char *name, const unsigned int syscall_no, const dyn_syscall_t fp); int hijack_syscall(const char *name, const unsigned int syscall_no, const dyn_syscall_t fp); DESCRIPTION "dyn_syscall_reg()" and "hijack_syscall()" are exported services available for loadable kernel modules. "dyn_syscall_reg()" registers a new, dynamic system call. If "syscall_no" is zero, then an otherwise unused system call number will be assigned. "hijack_syscall()" registers a system call which overloads an existing one. "name" points to a string that shall persist while the system call is alive. "syscall_no" should be in the range of [__NR_ni_syscall + 1... __NR_ni_syscall + NR_syscalls). "fp" refers to the new system call. For the IA64 architecture, the function descriptor "dyn_syscall_t" refers to a structure containing the program counter and the global pointer. User applications can find this system call number in "/proc/sys/kernel/dynamic_syscalls/" or in "/proc/sys/kernel/hijacked_syscalls/", respectively. On read, each of these files contains a 4 digit decimal number terminated with a '\n' character. RETURN VALUE On success, the system call number accepted / assigned is returned. On error, the following codes may be returned: -ENOENT: No more free system call is available - "dyn_syscall_reg()" only -EINVAL: Illegal system call number - both -EBUSY: System call is already in use - "dyn_syscall_reg()" only -ENOMEM: Cannot create "/proc/..." - both SEE ALSO syscall_unlock, prep_restore_syscall, syscall_trylock, dyn_syscall_unreg, restore_syscall -------------------------------------------------------------------------------- NAME syscall_unlock, syscall_trylock - Unlock / try to lock a system call prep_restore_syscall - Prepare to unregister a system call SYNOPSIS #include int syscall_unlock(const char *name, const unsigned int syscall_no); int syscall_trylock(const char *name, const unsigned int syscall_no); int prep_restore_syscall(const char *name, const unsigned int syscall_no); DESCRIPTION "syscall_unlock()", "syscall_trylock()" and "prep_restore_syscall()" are exported services available for loadable kernel modules. Each system call is protected by a semaphore. When a new system call is added, it is locked for write. Regular system call invocation tries to take the semaphore for read. Unless it is "syscall_unlock()"-ed, any attempt to use the system call will be refused and "-ENOSYS" will be reported. Before undoing a system call registration, it is necessary to lock out any further invocation of the system call by re-locking it for write. (They will be refused by returning "-ENOSYS".) Apart from some small administration task, "prep_restore_syscall()" attempts to do it. If it fails (indicated by "-EAGAIN" returned), then there is at least one "living call" which may be "part way" through the system call code. "syscall_trylock()" should be invoked repeatedly while it returns "-EAGAIN". In order not to over penalise other tasks, "schedule()" should be invoked at each iteration. If the system call is blocking, i.e. there can be tasks sleeping inside the system call, then they have to be woke up. In such a case, it is recommended to sleep a bit between two iterations of "syscall_trylock()". "name" should be the same as that was used during the registration. "syscall_no" should be in the range of [__NR_ni_syscall + 1... __NR_ni_syscall + NR_syscalls). RETURN VALUE On success, zero is returned. "syscall_trylock()" and "prep_restore_syscall()" return "-EAGAIN" if they have failed to take the semaphore for write. On error, the following codes can be returned: -EBADF: Name or system call number does not match the parameters which was used during the system call registration -EINVAL: Illegal system call number SEE ALSO dyn_syscall_reg, hijack_syscall, dyn_syscall_unreg, restore_syscall -------------------------------------------------------------------------------- NAME dyn_syscall_unreg, restore_syscall - Unregister a system call SYNOPSIS #include int dyn_syscall_unreg(const char *name, const unsigned int syscall_no); int restore_syscall(const char *name, const unsigned int syscall_no); DESCRIPTION "dyn_syscall_unreg()" and "restore_syscall()" are exported services available for loadable kernel modules. "dyn_syscall_unreg()" unregisters a dynamic system call. "restore_syscall()" restores a hijacked system call. "name" should be the same as that was used during the registration. "syscall_no" should be in the range of [__NR_ni_syscall + 1... __NR_ni_syscall + NR_syscalls). RETURN VALUE On success, zero is returned. On error, the following codes can be returned: -EBADF: Name or system call number does not match the parameters which was used during the system call registration -EINVAL: Illegal system call number SEE ALSO dyn_syscall_reg, hijack_syscall, syscall_unlock, syscall_trylock, prep_restore_syscall