Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 320534
b: refs/heads/master
c: a427b9e
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and Trond Myklebust committed Jul 30, 2012
1 parent c8939a9 commit d05e636
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5cf02d09b50b1ee1c2d536c9cf64af5a7d433f56
refs/heads/master: a427b9ec4eda8cd6e641ea24541d30b641fc3140
26 changes: 20 additions & 6 deletions trunk/fs/nfs/idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,18 @@ static int nfs_idmap_init_keyring(void)
if (ret < 0)
goto failed_put_key;

ret = register_key_type(&key_type_id_resolver_legacy);
if (ret < 0)
goto failed_reg_legacy;

set_bit(KEY_FLAG_ROOT_CAN_CLEAR, &keyring->flags);
cred->thread_keyring = keyring;
cred->jit_keyring = KEY_REQKEY_DEFL_THREAD_KEYRING;
id_resolver_cache = cred;
return 0;

failed_reg_legacy:
unregister_key_type(&key_type_id_resolver);
failed_put_key:
key_put(keyring);
failed_put_cred:
Expand All @@ -222,6 +228,7 @@ static void nfs_idmap_quit_keyring(void)
{
key_revoke(id_resolver_cache->thread_keyring);
unregister_key_type(&key_type_id_resolver);
unregister_key_type(&key_type_id_resolver_legacy);
put_cred(id_resolver_cache);
}

Expand Down Expand Up @@ -385,7 +392,7 @@ static const struct rpc_pipe_ops idmap_upcall_ops = {
};

static struct key_type key_type_id_resolver_legacy = {
.name = "id_resolver",
.name = "id_legacy",
.instantiate = user_instantiate,
.match = user_match,
.revoke = user_revoke,
Expand Down Expand Up @@ -674,6 +681,7 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
if (ret < 0)
goto out2;

BUG_ON(idmap->idmap_key_cons != NULL);
idmap->idmap_key_cons = cons;

ret = rpc_queue_upcall(idmap->idmap_pipe, msg);
Expand All @@ -687,8 +695,7 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
out1:
kfree(msg);
out0:
key_revoke(cons->key);
key_revoke(cons->authkey);
complete_request_key(cons, ret);
return ret;
}

Expand Down Expand Up @@ -722,11 +729,18 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
{
struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode);
struct idmap *idmap = (struct idmap *)rpci->private;
struct key_construction *cons = idmap->idmap_key_cons;
struct key_construction *cons;
struct idmap_msg im;
size_t namelen_in;
int ret;

/* If instantiation is successful, anyone waiting for key construction
* will have been woken up and someone else may now have used
* idmap_key_cons - so after this point we may no longer touch it.
*/
cons = ACCESS_ONCE(idmap->idmap_key_cons);
idmap->idmap_key_cons = NULL;

if (mlen != sizeof(im)) {
ret = -ENOSPC;
goto out;
Expand All @@ -739,7 +753,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)

if (!(im.im_status & IDMAP_STATUS_SUCCESS)) {
ret = mlen;
complete_request_key(idmap->idmap_key_cons, -ENOKEY);
complete_request_key(cons, -ENOKEY);
goto out_incomplete;
}

Expand All @@ -756,7 +770,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
}

out:
complete_request_key(idmap->idmap_key_cons, ret);
complete_request_key(cons, ret);
out_incomplete:
return ret;
}
Expand Down

0 comments on commit d05e636

Please sign in to comment.