lkml.org 
[lkml]   [2020]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH v7 2/9] pidfd: Add missing sock updates for pidfd_getfd()
    On Thu, Jul 9, 2020 at 8:26 PM Kees Cook <keescook@chromium.org> wrote:
    > The sock counting (sock_update_netprioidx() and sock_update_classid())
    > was missing from pidfd's implementation of received fd installation. Add
    > a call to the new __receive_sock() helper.
    [...]
    > diff --git a/kernel/pid.c b/kernel/pid.c
    [...]
    > @@ -642,10 +643,12 @@ static int pidfd_getfd(struct pid *pid, int fd)
    > }
    >
    > ret = get_unused_fd_flags(O_CLOEXEC);
    > - if (ret < 0)
    > + if (ret < 0) {
    > fput(file);
    > - else
    > + } else {
    > fd_install(ret, file);
    > + __receive_sock(file);
    > + }

    __receive_sock() has to be before fd_install(), otherwise `file` can
    be a dangling pointer.

    \
     
     \ /
      Last update: 2020-07-09 22:02    [W:2.295 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site