lkml.org 
[lkml]   [2020]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.6 049/194] umh: fix memory leak on execve failure
    Date
    From: Vincent Minet <v.minet@criteo.com>

    [ Upstream commit db803036ada7d61d096783726f9771b3fc540370 ]

    If a UMH process created by fork_usermode_blob() fails to execute,
    a pair of struct file allocated by umh_pipe_setup() will leak.

    Under normal conditions, the caller (like bpfilter) needs to manage the
    lifetime of the UMH and its two pipes. But when fork_usermode_blob()
    fails, the caller doesn't really have a way to know what needs to be
    done. It seems better to do the cleanup ourselves in this case.

    Fixes: 449325b52b7a ("umh: introduce fork_usermode_blob() helper")
    Signed-off-by: Vincent Minet <v.minet@criteo.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    kernel/umh.c | 6 ++++++
    1 file changed, 6 insertions(+)

    --- a/kernel/umh.c
    +++ b/kernel/umh.c
    @@ -475,6 +475,12 @@ static void umh_clean_and_save_pid(struc
    {
    struct umh_info *umh_info = info->data;

    + /* cleanup if umh_pipe_setup() was successful but exec failed */
    + if (info->pid && info->retval) {
    + fput(umh_info->pipe_to_umh);
    + fput(umh_info->pipe_from_umh);
    + }
    +
    argv_free(info->argv);
    umh_info->pid = info->pid;
    }

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