0

I have a Kernel module program which executes an userspace app named binary as shown below.

    struct subprocess_info *info;
    static char *envp[] = {
            "HOME=/",
            "TERM=linux",
            "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
            NULL
    };
    static char *binary_path = "/usr/bin/binary";

    char **argv = kmalloc(sizeof(char *[2]), GFP_KERNEL);
    if (!argv)
            return -ENOMEM;

    argv[0] = binary_path;
    argv[1] = NULL;

    info = call_usermodehelper_setup(binary_path, argv, envp, GFP_KERNEL,
                                     NULL, <some_free_function>, NULL);
    if (info) {
            return call_usermodehelper_exec(info, (UMH_WAIT_PROC | UMH_KILLABLE));
    }

This type of design is must for me executing binary as it depends on some /dev/* files.

This is working very fine in normal environment but when I am trying to insmod this binary from a docker then binary is not starting at all.

Binary and its dependent libraries are not in host's rootfs. They are in docker's.

When I moved this binary and dependent libraries to host then every thing is fine.

How can I execute this from docker without any fail.

Sriram.K
  • 45
  • 7
  • Possible duplicate of [Docker loading kernel modules](https://stackoverflow.com/questions/33013539/docker-loading-kernel-modules) – Tsyvarev Apr 23 '18 at 21:15
  • Actually that question is about inserting a module. In my scenario its about invoking userspace app from kernel module which is being inserted from docker. – Sriram.K Apr 24 '18 at 12:01
  • The referenced question is about *inserting module into docker's container*. (Well, it asks about `xfsprogs`, which is not actually a module, but the answers are about kernel modules). The [accepted answer](https://stackoverflow.com/a/33017933/3440745) says, that you cannot insert a module into the docker container. Is your problem different? – Tsyvarev Apr 24 '18 at 12:27
  • 1
    to insert a module from docker its needed to start docker in privileged mode. I am starting docker in privileged mode only. My question is about inserting a module which invokes userland application. Module insertion is working but userland app is not working. I need to map some docker files to host to make it working. I dont know how to do it. – Sriram.K Apr 25 '18 at 10:12

0 Answers0