aboutsummaryrefslogtreecommitdiff
path: root/security/keys/keyctl.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-27 11:07:19 +0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-22 23:57:56 +0400
commit67d1214551e800f9fe7dc7c47a346d2df0fafed5 (patch)
treeffcc93af9390339adda36668255e617073b724a1 /security/keys/keyctl.c
parent158e1645e07f3e9f7e4962d7a0997f5c3b98311b (diff)
downloadlinaro-lsk-67d1214551e800f9fe7dc7c47a346d2df0fafed5.tar.gz
merge task_work and rcu_head, get rid of separate allocation for keyring case
task_work and rcu_head are identical now; merge them (calling the result struct callback_head, rcu_head #define'd to it), kill separate allocation in security/keys since we can just use cred->rcu now. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security/keys/keyctl.c')
-rw-r--r--security/keys/keyctl.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 26723caaad0..0291b3f9397 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1456,8 +1456,7 @@ long keyctl_session_to_parent(void)
{
struct task_struct *me, *parent;
const struct cred *mycred, *pcred;
- struct kludge *newwork;
- struct task_work *oldwork;
+ struct callback_head *newwork, *oldwork;
key_ref_t keyring_r;
struct cred *cred;
int ret;
@@ -1467,20 +1466,17 @@ long keyctl_session_to_parent(void)
return PTR_ERR(keyring_r);
ret = -ENOMEM;
- newwork = kmalloc(sizeof(struct kludge), GFP_KERNEL);
- if (!newwork)
- goto error_keyring;
/* our parent is going to need a new cred struct, a new tgcred struct
* and new security data, so we allocate them here to prevent ENOMEM in
* our parent */
cred = cred_alloc_blank();
if (!cred)
- goto error_newwork;
+ goto error_keyring;
+ newwork = &cred->rcu;
cred->tgcred->session_keyring = key_ref_to_ptr(keyring_r);
- init_task_work(&newwork->twork, key_change_session_keyring);
- newwork->cred = cred;
+ init_task_work(newwork, key_change_session_keyring);
me = current;
rcu_read_lock();
@@ -1529,24 +1525,18 @@ long keyctl_session_to_parent(void)
/* the replacement session keyring is applied just prior to userspace
* restarting */
- ret = task_work_add(parent, &newwork->twork, true);
+ ret = task_work_add(parent, newwork, true);
if (!ret)
newwork = NULL;
unlock:
write_unlock_irq(&tasklist_lock);
rcu_read_unlock();
- if (oldwork) {
- put_cred(container_of(oldwork, struct kludge, twork)->cred);
- kfree(oldwork);
- }
- if (newwork) {
- put_cred(newwork->cred);
- kfree(newwork);
- }
+ if (oldwork)
+ put_cred(container_of(oldwork, struct cred, rcu));
+ if (newwork)
+ put_cred(cred);
return ret;
-error_newwork:
- kfree(newwork);
error_keyring:
key_ref_put(keyring_r);
return ret;