aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-26 22:10:04 +0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-22 23:57:54 +0400
commit41f9d29f09ca0b22c3631e8a39676e74cda9bcc0 (patch)
tree7ab5ed25f14466471fb55536e1cf71c514fb7fe9 /security/keys
parent7266702805f9d824f92ce5c4069eca65d0f21d28 (diff)
downloadkernel_goldelico_gta04-41f9d29f09ca0b22c3631e8a39676e74cda9bcc0.zip
kernel_goldelico_gta04-41f9d29f09ca0b22c3631e8a39676e74cda9bcc0.tar.gz
kernel_goldelico_gta04-41f9d29f09ca0b22c3631e8a39676e74cda9bcc0.tar.bz2
trimming task_work: kill ->data
get rid of the only user of ->data; this is _not_ the final variant - in the end we'll have task_work and rcu_head identical and just use cred->rcu, at which point the separate allocation will be gone completely. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security/keys')
-rw-r--r--security/keys/internal.h4
-rw-r--r--security/keys/keyctl.c14
-rw-r--r--security/keys/process_keys.c5
3 files changed, 15 insertions, 8 deletions
diff --git a/security/keys/internal.h b/security/keys/internal.h
index 3dcbf86..b510a31 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -148,6 +148,10 @@ extern key_ref_t lookup_user_key(key_serial_t id, unsigned long flags,
#define KEY_LOOKUP_PARTIAL 0x02
#define KEY_LOOKUP_FOR_UNLINK 0x04
+struct kludge { /* this will die off very soon */
+ struct task_work twork;
+ struct cred *cred;
+};
extern long join_session_keyring(const char *name);
extern void key_change_session_keyring(struct task_work *twork);
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 0f5b3f0..26723ca 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1456,7 +1456,8 @@ long keyctl_session_to_parent(void)
{
struct task_struct *me, *parent;
const struct cred *mycred, *pcred;
- struct task_work *newwork, *oldwork;
+ struct kludge *newwork;
+ struct task_work *oldwork;
key_ref_t keyring_r;
struct cred *cred;
int ret;
@@ -1466,7 +1467,7 @@ long keyctl_session_to_parent(void)
return PTR_ERR(keyring_r);
ret = -ENOMEM;
- newwork = kmalloc(sizeof(struct task_work), GFP_KERNEL);
+ newwork = kmalloc(sizeof(struct kludge), GFP_KERNEL);
if (!newwork)
goto error_keyring;
@@ -1478,7 +1479,8 @@ long keyctl_session_to_parent(void)
goto error_newwork;
cred->tgcred->session_keyring = key_ref_to_ptr(keyring_r);
- init_task_work(newwork, key_change_session_keyring, cred);
+ init_task_work(&newwork->twork, key_change_session_keyring);
+ newwork->cred = cred;
me = current;
rcu_read_lock();
@@ -1527,18 +1529,18 @@ long keyctl_session_to_parent(void)
/* the replacement session keyring is applied just prior to userspace
* restarting */
- ret = task_work_add(parent, newwork, true);
+ ret = task_work_add(parent, &newwork->twork, true);
if (!ret)
newwork = NULL;
unlock:
write_unlock_irq(&tasklist_lock);
rcu_read_unlock();
if (oldwork) {
- put_cred(oldwork->data);
+ put_cred(container_of(oldwork, struct kludge, twork)->cred);
kfree(oldwork);
}
if (newwork) {
- put_cred(newwork->data);
+ put_cred(newwork->cred);
kfree(newwork);
}
return ret;
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 4ad54ee..c9b07c9 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -837,9 +837,10 @@ error:
void key_change_session_keyring(struct task_work *twork)
{
const struct cred *old = current_cred();
- struct cred *new = twork->data;
+ struct kludge *p = container_of(twork, struct kludge, twork);
+ struct cred *new = p->cred;
- kfree(twork);
+ kfree(p);
if (unlikely(current->flags & PF_EXITING)) {
put_cred(new);
return;