diff options
author | Jeff Layton <jlayton@poochiereds.net> | 2015-06-24 12:10:23 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-08-03 09:29:17 -0700 |
commit | 1488271989894c89ddac1fa6764edb89421c2160 (patch) | |
tree | 312096a02ff527c1a13183c71fee8a5cc4a4e61c /fs/nfs | |
parent | a400ef50e78554c779742d45c6f7bfa4fa39d990 (diff) | |
download | lwn-1488271989894c89ddac1fa6764edb89421c2160.tar.gz lwn-1488271989894c89ddac1fa6764edb89421c2160.zip |
nfs: fix potential credential leak in ff_layout_update_mirror_cred
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>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/flexfilelayout/flexfilelayoutdev.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index 77a2d026aa12..c19b9a88f748 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c @@ -324,7 +324,8 @@ static int ff_layout_update_mirror_cred(struct nfs4_ff_layout_mirror *mirror, __func__, PTR_ERR(cred)); return PTR_ERR(cred); } else { - mirror->cred = cred; + if (cmpxchg(&mirror->cred, NULL, cred)) + put_rpccred(cred); } } return 0; |