Discussion:
call_usermodehelper() kernel panic!
(too old to reply)
Eviltime
2007-01-26 18:43:18 UTC
Permalink
Raw Message
Hi, i was trying to execute an user space program through a kernel module,
i've used the same method of linux-$KERNELVERSION/drivers/usb/usb.c, and this is the interesting code..

[...]
char *argv[3];
char *envp[3];

argv [0] = "/usr/sbin/httpd";
argv [1] = "httpd";
argv [2] = 0;

envp[0] = "HOME=/";
envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
envp[2] = 0;

call_usermodehelper(argv [0], argv, envp);
[...]

but when I run it, it causes a kernel panic during the call_usermodehelper() call.. this is the kernel panic message:

kernel BUG at sched.c:564
invalid operand: 0000
CPU: 0
EIP: 0010:[<c0114d7b] Not tainted
EFLAGS: 00010282
[...]
<0> Kernel panic: Aiee, killing interrupt handler!
In interrupt handler - not syncing

----------

any help is welcome!!
Thanks in advance

Marco


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Curran, Dominic
2007-01-26 20:34:32 UTC
Permalink
Raw Message
Post by Eviltime
Hi, i was trying to execute an user space program through a kernel module,
i've used the same method of linux-$KERNELVERSION/drivers/usb/usb.c,
and
Post by Eviltime
this is the interesting code..
[...]
char *argv[3];
char *envp[3];
argv [0] = "/usr/sbin/httpd";
argv [1] = "httpd";
argv [2] = 0;
envp[0] = "HOME=/";
envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
envp[2] = 0;
call_usermodehelper(argv [0], argv, envp);
[...]
but when I run it, it causes a kernel panic during the
kernel BUG at sched.c:564
invalid operand: 0000
CPU: 0
EIP: 0010:[<c0114d7b] Not tainted
EFLAGS: 00010282
[...]
<0> Kernel panic: Aiee, killing interrupt handler!
In interrupt handler - not syncing
Are you calling call_usermodehelper() from within an interrupt handler ?

I believe call_usermodehelper() must be called from a context that can
wait.

To test this you can try to use the define in_atomic(). If it returns
TRUE then you are in a context that can't wait.

dom

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Jiri Kosina
2007-01-26 21:27:32 UTC
Permalink
Raw Message
Post by Eviltime
call_usermodehelper(argv [0], argv, envp);
[...]
but when I run it, it causes a kernel panic during the call_usermodehelper()
<0> Kernel panic: Aiee, killing interrupt handler!
In interrupt handler - not syncing
This indicates that you are calling call_usermodhelper() from within an
interrupt context. This would never work, because of call_usermodhelper()
-> call_usermodehelper_keys() -> wait_for_completion() -> schedule() ->
boom. You can't schedule from an interrupt context.

This fact is even mentioned in the comment of call_usermodehelper_keys()
function.
--
Jiri Kosina

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Eviltime
2007-01-26 23:03:31 UTC
Permalink
Raw Message
Post by Jiri Kosina
Post by Eviltime
call_usermodehelper(argv [0], argv, envp);
[...]
but when I run it, it causes a kernel panic during the call_usermodehelper()
<0> Kernel panic: Aiee, killing interrupt handler!
In interrupt handler - not syncing
This indicates that you are calling call_usermodhelper() from within an
interrupt context. This would never work, because of call_usermodhelper()
-> call_usermodehelper_keys() -> wait_for_completion() -> schedule() ->
boom. You can't schedule from an interrupt context.
This fact is even mentioned in the comment of call_usermodehelper_keys()
function.
Really thanks for the answers..
I'm trying to call it into a nf_hook_ops registered function ..
there's another way to execute a local file when a specified packet it's received?


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Jiri Kosina
2007-01-27 00:05:44 UTC
Permalink
Raw Message
Really thanks for the answers.. I'm trying to call it into a nf_hook_ops
registered function .. there's another way to execute a local file when
a specified packet it's received?
This would very probably impose a significant overhead and will open easy
way to DoS the box. Executing binaries is too expensive to be done for
every received network packet.

Either do this completely in userspace (see libpcap library, which will
pass all the incoming packets into your application), or if you really
want to do it in kernelspace, then you could consider using workqueues
(schedule work on workqueue in interrupt context, the work will be
executed later as a bottom half, in process context).
--
Jiri Kosina

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Loading...