Re: Weird behaviour in select() in 2.2.12-20

From: Brian Gerst (bgerst@quark.vpplus.com)
Date: Tue Jul 18 2000 - 15:56:43 EST


Timothy Knox wrote:
>
> We are developing a Linux kernel module for kernel 2.2.12-20. This module
> interecepts a number of system calls. It does so by replacing the address
> in the sys_call_table. For example:
>
> // save the old system call
> o_socketcall = sys_call_table [SYS_socketcall];
> // replace with our code
> sys_call_table [SYS_socketcall] = n_socketcall;

First of all, why do you need to intercept system calls like this from
the kernel? Is this something that can't be done from user space using
ptrace?

> We ran our test client/server pair (applications we wrote, that call
> select) and got no messages from sys_select. Next, we inserted our
> module, and ran the c/s pair again. We still got no messages from
> sys_select. Finally, we removed our module, which gave a kernel Oops for
> VM (unable to handle kernel paging request (a known bug in our module
> that we have not yet fixed)). When we subsequently ran the c/s pair
> again, we began getting log messages from sys_select.

The syscall code does not have the proper module locking needed for
calling syscalls in a module. Nor do we want it. That would just cause
slowdowns for all syscalls when 99.9% of them are built-in. The oops
happens because some task is sleeping in your function and the module
gets unloaded from under it. The moral of the story: don't muck with
sys_call_table.

> So, my questions are: Why is the system select not getting called until
> we go through all of the above? Why, for that matter, does the address in
> the sys_call_table differ from the address of the routine that gets
> called? Who is intercepting or keeping select from going through the
> system call table? How do we fix it?

At least in 2.4.0-test4, there are two select() syscalls: old_select and
sys_select. I don't have a 2.2 kernel handy to verify if that version
has both, but it is a likely guess.

--

Brian Gerst

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jul 23 2000 - 21:00:11 EST