accessing the struct task_struct using a pid
guys,
I am writing a kernel module where I am trying to
access the task_structs. Now I have tried this using various mathods.
1) Using the pidhash array.
Here when I do a insmod I get a unresolved
symbol.
2) Directly accessing the location of pidhash as
seen in System.map.
Here when the pidhash_fn hashes the supplied pid
the particular location into which it indexes in NULL.
3) Starting from the init_task.
here the next task after the init task is found
to be NULL.
Could some one help me in this matter.
-vangough
Following is the piece of code which executes when an apploication program does a sys_ptrace.
int new_syscall(long request,long pid,long addr,long data)
struct task_struct *my_init_task = (structtask_struct *)&init_task;
struct task_struct *task_ptr; if(my_init_task)
{
task_ptr = my_init_task;
while(task_ptr && (task_ptr->next_task !=
my_init_task))
{
printk("<1> task_ptr pointer is %x\n",task_ptr);
printk("<1> task_ptr->pid is %d\n",task_ptr->pid);
printk("<1> task_ptr->next_task is
%x",task_ptr->next_task);
task_ptr = (struct task_struct*)task_ptr->next_task;
}
}
else
{
printk("<1> my_init_task pointer is
%d\n",my_init_task);
return 0;}
_memcpy(sys_call_table[SYS_PTRACE_NUMBER],syscall_code,
sizeof(syscall_code));
/* ((long int (*) (long,long,long,long))sys_call_table[SYS_PTRACE_NUMBER])(request,pid,addr,data);*/ }
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
Quoted 5 lines · Amit Nadgar
I am writing a kernel module where I am trying to
access thetask_structs. Now I have tried this using various mathods.
1) Using the pidhash array.
Here when I do a insmod I get a unresolved symbol.
EXPORT_SYMBOL(pidhash) or something. Make sure you included sched.h
Quoted 3 lines · Amit Nadgar
2) Directly accessing the location of pidhash as seen in System.map. Here when the
pidhash_fnhashes the supplied pid the particular location into which it indexes in NULL.
How early are you trying to do this?
Quoted 2 lines · Amit Nadgar
3) Starting from the
init_task.
here the next task after the init task is found to be NULL.
Don't do that.
Quoted 1 line · Amit Nadgar
Could some one help me in this matter.
I'm afraid there's only so much help that can be given. Some effort may be required on your part to make this work. Help with basic concepts and Linux conventions is more likely to be found on irc.openprojects.net #kernelnewbies or the [email protected] mailing list.
Cheers,
Bill