lkml.org 
[lkml]   [2015]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.1 248/267] nfs: fix potential credential leak in ff_layout_update_mirror_cred
    Date
    4.1-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Jeff Layton <jlayton@poochiereds.net>

    commit a24221dca1868101c9b4b5adde4a6a5b1a3a64a7 upstream.

    If we have two tasks racing to update a mirror's credentials, then they
    can end up leaking one (or more) sets of credentials. The first task
    will set mirror->cred and then the second task will just overwrite it.

    Use a cmpxchg to ensure that the creds are only set once. If we get to
    the point where we would set mirror->cred and find that they're already
    set, then we just release the creds that were just found.

    Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
    Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    fs/nfs/flexfilelayout/flexfilelayoutdev.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
    +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
    @@ -324,7 +324,8 @@ static int ff_layout_update_mirror_cred(
    __func__, PTR_ERR(cred));
    return PTR_ERR(cred);
    } else {
    - mirror->cred = cred;
    + if (cmpxchg(&mirror->cred, NULL, cred))
    + put_rpccred(cred);
    }
    }
    return 0;



    \
     
     \ /
      Last update: 2015-07-31 23:41    [W:4.050 / U:24.940 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site