21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have EXPORT_.*_SYMBOL_GPL inside which was used in the
    initial scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

12 Jan, 2019

1 commit

  • A UMH process which is created by the fork_usermode_blob() such as
    bpfilter needs to release members of the umh_info when process is
    terminated.
    But the do_exit() does not release members of the umh_info. hence module
    which uses UMH needs own code to detect whether UMH process is
    terminated or not.
    But this implementation needs extra code for checking the status of
    UMH process. it eventually makes the code more complex.

    The new PF_UMH flag is added and it is used to identify UMH processes.
    The exit_umh() does not release members of the umh_info.
    Hence umh_info->cleanup callback should release both members of the
    umh_info and the private data.

    Suggested-by: David S. Miller
    Signed-off-by: Taehee Yoo
    Signed-off-by: David S. Miller

    Taehee Yoo
     

23 Oct, 2018

1 commit

  • User mode helpers were spawned without a command line, and because
    an empty command line is used by many tools to identify processes as
    kernel threads, this could cause some issues.

    Notably during killing spree on shutdown, since such helper would then
    be skipped (i.e. not killed) which would result in the process remaining
    alive, and thus preventing unmouting of the rootfs (as experienced with
    the bpfilter umh).

    Fixes: 449325b52b7a ("umh: introduce fork_usermode_blob() helper")
    Signed-off-by: Olivier Brunel
    Signed-off-by: David S. Miller

    Olivier Brunel
     

08 Jun, 2018

1 commit

  • kasan reported use-after-free:
    BUG: KASAN: use-after-free in call_usermodehelper_exec_work+0x2d3/0x310 kernel/umh.c:195
    Write of size 4 at addr ffff8801d9202370 by task kworker/u4:2/50
    Workqueue: events_unbound call_usermodehelper_exec_work
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x1b9/0x294 lib/dump_stack.c:113
    print_address_description+0x6c/0x20b mm/kasan/report.c:256
    kasan_report_error mm/kasan/report.c:354 [inline]
    kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
    __asan_report_store4_noabort+0x17/0x20 mm/kasan/report.c:437
    call_usermodehelper_exec_work+0x2d3/0x310 kernel/umh.c:195
    process_one_work+0xc1e/0x1b50 kernel/workqueue.c:2145
    worker_thread+0x1cc/0x1440 kernel/workqueue.c:2279
    kthread+0x345/0x410 kernel/kthread.c:240
    ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412

    The reason is that 'sub_info' cannot be accessed out of parent task
    context, since it will be freed by the child.
    Instead remember the pid in the child task.

    Fixes: 449325b52b7a ("umh: introduce fork_usermode_blob() helper")
    Reported-by: syzbot+2c73319c406f1987d156@syzkaller.appspotmail.com
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: David S. Miller

    Alexei Starovoitov
     

24 May, 2018

1 commit

  • Introduce helper:
    int fork_usermode_blob(void *data, size_t len, struct umh_info *info);
    struct umh_info {
    struct file *pipe_to_umh;
    struct file *pipe_from_umh;
    pid_t pid;
    };

    that GPLed kernel modules (signed or unsigned) can use it to execute part
    of its own data as swappable user mode process.

    The kernel will do:
    - allocate a unique file in tmpfs
    - populate that file with [data, data + len] bytes
    - user-mode-helper code will do_execve that file and, before the process
    starts, the kernel will create two unix pipes for bidirectional
    communication between kernel module and umh
    - close tmpfs file, effectively deleting it
    - the fork_usermode_blob will return zero on success and populate
    'struct umh_info' with two unix pipes and the pid of the user process

    As the first step in the development of the bpfilter project
    the fork_usermode_blob() helper is introduced to allow user mode code
    to be invoked from a kernel module. The idea is that user mode code plus
    normal kernel module code are built as part of the kernel build
    and installed as traditional kernel module into distro specified location,
    such that from a distribution point of view, there is
    no difference between regular kernel modules and kernel modules + umh code.
    Such modules can be signed, modprobed, rmmod, etc. The use of this new helper
    by a kernel module doesn't make it any special from kernel and user space
    tooling point of view.

    Such approach enables kernel to delegate functionality traditionally done
    by the kernel modules into the user space processes (either root or !root) and
    reduces security attack surface of the new code. The buggy umh code would crash
    the user process, but not the kernel. Another advantage is that umh code
    of the kernel module can be debugged and tested out of user space
    (e.g. opening the possibility to run clang sanitizers, fuzzers or
    user space test suites on the umh code).
    In case of the bpfilter project such architecture allows complex control plane
    to be done in the user space while bpf based data plane stays in the kernel.

    Since umh can crash, can be oom-ed by the kernel, killed by the admin,
    the kernel module that uses them (like bpfilter) needs to manage life
    time of umh on its own via two unix pipes and the pid of umh.

    The exit code of such kernel module should kill the umh it started,
    so that rmmod of the kernel module will cleanup the corresponding umh.
    Just like if the kernel module does kmalloc() it should kfree() it
    in the exit code.

    Signed-off-by: Alexei Starovoitov
    Signed-off-by: David S. Miller

    Alexei Starovoitov
     

03 Apr, 2018

1 commit

  • All call sites of sys_wait4() set *rusage to NULL. Therefore, there is
    no need for the copy_to_user() handling of *rusage, and we can use
    kernel_wait4() directly.

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Acked-by: Luis R. Rodriguez
    Cc: Al Viro
    Cc: Andrew Morton
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     

18 Nov, 2017

1 commit


09 Sep, 2017

1 commit

  • Patch series "kmod: few code cleanups to split out umh code"

    The usermode helper has a provenance from the old usb code which first
    required a usermode helper. Eventually this was shoved into kmod.c and
    the kernel's modprobe calls was converted over eventually to share the
    same code. Over time the list of usermode helpers in the kernel has grown
    -- so kmod is just but one user of the API.

    This series is a simple logical cleanup which acknowledges the code
    evolution of the usermode helper and shoves the UMH API into its own
    dedicated file. This way users of the API can later just include umh.h
    instead of kmod.h.

    Note despite the diff state the first patch really is just a code shove,
    no functional changes are done there. I did use git format-patch -M to
    generate the patch, but in the end the split was not enough for git to
    consider it a rename hence the large diffstat.

    I've put this through 0-day and it gives me their machine compilation
    blessings with all tests as OK.

    This patch (of 4):

    There's a slew of usermode helper users and kmod is just one of them.
    Split out the usermode helper code into its own file to keep the logic and
    focus split up.

    This change provides no functional changes.

    Link: http://lkml.kernel.org/r/20170810180618.22457-2-mcgrof@kernel.org
    Signed-off-by: Luis R. Rodriguez
    Cc: Kees Cook
    Cc: Dmitry Torokhov
    Cc: Jessica Yu
    Cc: Rusty Russell
    Cc: Michal Marek
    Cc: Petr Mladek
    Cc: Miroslav Benes
    Cc: Josh Poimboeuf
    Cc: Guenter Roeck
    Cc: "Eric W. Biederman"
    Cc: Matt Redfearn
    Cc: Dan Carpenter
    Cc: Colin Ian King
    Cc: Daniel Mentz
    Cc: David Binderman
    Cc: Greg Kroah-Hartman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luis R. Rodriguez