|
@@ -1456,8 +1456,7 @@ long keyctl_session_to_parent(void)
|
|
{
|
|
{
|
|
struct task_struct *me, *parent;
|
|
struct task_struct *me, *parent;
|
|
const struct cred *mycred, *pcred;
|
|
const struct cred *mycred, *pcred;
|
|
- struct kludge *newwork;
|
|
|
|
- struct task_work *oldwork;
|
|
|
|
|
|
+ struct callback_head *newwork, *oldwork;
|
|
key_ref_t keyring_r;
|
|
key_ref_t keyring_r;
|
|
struct cred *cred;
|
|
struct cred *cred;
|
|
int ret;
|
|
int ret;
|
|
@@ -1467,20 +1466,17 @@ long keyctl_session_to_parent(void)
|
|
return PTR_ERR(keyring_r);
|
|
return PTR_ERR(keyring_r);
|
|
|
|
|
|
ret = -ENOMEM;
|
|
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
|
|
/* 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
|
|
* and new security data, so we allocate them here to prevent ENOMEM in
|
|
* our parent */
|
|
* our parent */
|
|
cred = cred_alloc_blank();
|
|
cred = cred_alloc_blank();
|
|
if (!cred)
|
|
if (!cred)
|
|
- goto error_newwork;
|
|
|
|
|
|
+ goto error_keyring;
|
|
|
|
+ newwork = &cred->rcu;
|
|
|
|
|
|
cred->tgcred->session_keyring = key_ref_to_ptr(keyring_r);
|
|
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;
|
|
me = current;
|
|
rcu_read_lock();
|
|
rcu_read_lock();
|
|
@@ -1529,24 +1525,18 @@ long keyctl_session_to_parent(void)
|
|
|
|
|
|
/* the replacement session keyring is applied just prior to userspace
|
|
/* the replacement session keyring is applied just prior to userspace
|
|
* restarting */
|
|
* restarting */
|
|
- ret = task_work_add(parent, &newwork->twork, true);
|
|
|
|
|
|
+ ret = task_work_add(parent, newwork, true);
|
|
if (!ret)
|
|
if (!ret)
|
|
newwork = NULL;
|
|
newwork = NULL;
|
|
unlock:
|
|
unlock:
|
|
write_unlock_irq(&tasklist_lock);
|
|
write_unlock_irq(&tasklist_lock);
|
|
rcu_read_unlock();
|
|
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;
|
|
return ret;
|
|
|
|
|
|
-error_newwork:
|
|
|
|
- kfree(newwork);
|
|
|
|
error_keyring:
|
|
error_keyring:
|
|
key_ref_put(keyring_r);
|
|
key_ref_put(keyring_r);
|
|
return ret;
|
|
return ret;
|