Weird behaviour in select() in 2.2.12-20

From: Timothy Knox (tdk@thelbane.com)
Date: Tue Jul 18 2000 - 15:32:34 EST


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;

We currently replace socketcall, read, write, ioctl, select, and close.
However, our new select is never called by the system. To investigate, I
built a kernel where sys_select prints a message to the syslog and the
console each time it is invoked.

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.

We had the kernel module print the address of the select call obtained
from the sys_call_table, which was: c010e070. According to /proc/ksyms,
that falls somewhere after do_gettimeofday. We also had the sys_select
print its address, which was: c012fc2c. According to /proc/ksyms, that
falls somewhere after __pollwait, as one might expect.

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?

NB All other calls (read, write, ioctl, close, and socketcall) are being
intercepted correctly. Only select is giving us a problem.

Any help, suggestions, or thoughts would be greatly appreciated.

-- 
Timothy Knox
tdk@thelbane.com
"The church is near but the road is icy; the bar is far away but
I will walk carefully." -- Russian proverb

- 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