From: hemanth nandish <hemanthluvsfifa@gmail.com>
To: kernelnewbies@kernelnewbies.org
Subject: Invoke binary from kernel space
Date: Fri, 24 Apr 2020 01:23:45 +0530 [thread overview]
Message-ID: <CAEBxVXMoDCyY3nbU0uEWSD2TivgujAYPQhWcLF=BbhrK0y6n=Q@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1127 bytes --]
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
[-- Attachment #1.2: Type: text/html, Size: 7664 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next reply other threads:[~2020-04-23 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 19:53 hemanth nandish [this message]
2020-04-23 20:58 ` Invoke binary from kernel space Valdis Klētnieks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEBxVXMoDCyY3nbU0uEWSD2TivgujAYPQhWcLF=BbhrK0y6n=Q@mail.gmail.com' \
--to=hemanthluvsfifa@gmail.com \
--cc=kernelnewbies@kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).