[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Recursion in process group statistical enumeration
On Monday 05 December 2005 07:37, thesp0nge wrote:
> Hi guys, I've got this problem and maybe you can give me an hint.
> My goal is, given a thread leader process task_struct, walk deeper in
> its childs and grandsons task_struct in order to count out how many
> times fork has been called out. I'm trying to do this in order to detect
> a fork bombing attack.
>
> This is the code I wrote. The problem is that after insmod it,
> ndiswrapper (used for mi wifi dongle) starts oops when trying to access
> network. After removing my code, ndiswrapper was still oopsing. I don't
> think it a ndiswrapper related issue because it happens just after I've
> introduced the following routine in task_create LSM hook.
>
> Am I missing something? :(
>
> int __angel_count_spawned_process(struct list_head *list)
> {
> struct list_head *p;
>
> if (list_empty(list))
> return 0;
> list_for_each(p, list)
> return 1 + __angel_count_spawned_process((struct list_head *)&((struct
> task_struct *)p)->children);
> }
>
> Thanks a lot
> sp0nge
> --
> Paolo Perego - <sponge@xxxxxxxxxxxxx> web: http://angel-lsm.sf.net
>
> Il C e' un ottimo sistema per spararsi in un piede. Con il C++ e' piu'
> difficile, ma se ci riuscite vi portera' via l'intera gamba.
> -- Bjarne Stroustrup
This is a recursive function. When programming in user space you have plenty
of stack. But in the kernel you have a fixed size stack (4 K or 8 K).
You have to be carefull how many levels of functions calls you have in your
code so you wont use all the stack.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/