lkml.org 
[lkml]   [2020]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: clean up and streamline probe_kernel_* and friends v2
    On Wed, May 13, 2020 at 4:04 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
    >
    > Aside from comments on list, the series looks reasonable to me. For BPF
    > the bpf_probe_read() helper would be slightly penalized for probing user
    > memory given we now test on copy_from_kernel_nofault() first and if that
    > fails only then fall back to copy_from_user_nofault(),

    Again, no.

    If you can't tell that one or the other is always the right thing,
    then that function is simply buggy and wrong.

    On sparc and on s390, address X can be _both_ a kernel address and a
    user address. You need to specify which it is (by using the proper
    function). The whole "try one first, then the other" doesn't work.
    They may both "work", and by virtue of that, unless you can state
    "yes, we always want user space" or "yes, we always want kernel", that
    "try one or the other" isn't valid.

    And it can be a real security issue. If a user program can be made to
    read kernel memory when BPF validated things as a user pointer, it's
    an obvious security issue.

    But it can be a security issue the other way around too: if the BPF
    code expects to get a kernel string, but user space can fool it into
    reading a user string instead by mapping something of its own into the
    user space address that aliases the kernel space address, then you can
    presumably fool the BPF program to do bad things too (eg mess up any
    BPF packet switching routines?).

    So BPF really really really needs to specify which one it is. Not
    specifying it and saying "whichever" is a bug, and a security issue.

    Linus

    \
     
     \ /
      Last update: 2020-05-14 01:20    [W:4.401 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site