Invoke binary from kernel space
hemanth nandish
hemanthluvsfifa at gmail.com
Thu Apr 23 15:53:45 EDT 2020
Hello,
I came across the function: call_usermodehelper
This can be used to invoke exec a binary from the kernel space.
It ultimately calls:
call_usermodehelper_exec_async
Which internally does:
retval = do_execve <https://elixir.bootlin.com/linux/v4.7/ident/do_execve>(
getname_kernel <https://elixir.bootlin.com/linux/v4.7/ident/getname_kernel>(
sub_info->path <https://elixir.bootlin.com/linux/v4.7/ident/path>),(const
char __user <https://elixir.bootlin.com/linux/v4.7/ident/__user> *const
__user <https://elixir.bootlin.com/linux/v4.7/ident/__user> *)sub_info->argv
<https://elixir.bootlin.com/linux/v4.7/ident/argv>,(const char __user
<https://elixir.bootlin.com/linux/v4.7/ident/__user> *const __user
<https://elixir.bootlin.com/linux/v4.7/ident/__user> *)sub_info->envp
<https://elixir.bootlin.com/linux/v4.7/ident/envp>);
This function works as expected and a new thread is spawned.
Now when I try to directly call do_execve within my module by passing the
required arguments, I am getting -EFAULT error.
This is happening in this function:
count(argv, MAX_ARG_STRINGS)
What am I missing here?
Thank you
Hemanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20200424/35ffa2df/attachment.html>
More information about the Kernelnewbies
mailing list