Nope, You are wrong, the poll system call is as follows
int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
No poll_tables are passed by the user process. You are confusing between the "poll" system call which a user process calls and the corresponding "poll" function which is called by the kernel in response to calling "poll" system call by the user. The "poll" function which is called and implemented by the device driver writer has following prototype
unsigned int (*poll) (struct file *, poll_table *);
This is called by kernel and not by user process and hence the poll_table is passed by the kernel.
I hope now it is clear that there is NO risk of exposing any kernel data structures.
HTH Regards Ketan
At 11:52 PM 7/26/2004, Dhiman, Gaurav wrote:
Hi,
Can anyone tell me the use of poll or select system call. Why we call poll_wait() function in poll or select system call for each of our wait queues maintained by our driver (refer to Rubini's chapter 5).
What exactly is the use of poll_wait() function.
I dig out the kernel sources for poll_wait function (which is a macro), it further calls __pollwait() function defined in select.c
Implementation of __pollwait() function can been seen at following link <http://lxr.linux.no/source/fs/select.c?v=2.4.21#L75>http://lxr.linux.no/source/fs/select.c?v=2.4.21#L75
As you can see at above link, __pollwait() function uses the poll_table, poll_table_page and poll_table_entry data structures.
Finally these structures are binding the wait queues passed as second argument in poll_wait() call with the poll_table (passed as a second argument in poll system call).
It means we are passing the pointers to the wait queues maintained by our device driver to the user process by poll_table , which the user process has passed thru system call. Is it not something dangerous, as we are exposing the kernel data structures (wait queues maintained by our driver) to the user process.
Wait queues further contain pointers to the task_struct structures representing process sleeping on that wait queue, so we are exposing a lot of kernel pointers and data structures to user process by means of poll_table pointer passed by user process as an argument to poll system call.
If I am wrong at some place, please correct me, other wise please help me to analyze the poll and select system calls in better way.
Finally I am also not able to understand the core purpose of providing wait queue details to user space thru poll or select system call.
Regards, Gaurav
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/