struct task_work {
struct hlist_node hlist;
task_work_func_t func;
- void *data;
};
static inline void
-init_task_work(struct task_work *twork, task_work_func_t func, void *data)
+init_task_work(struct task_work *twork, task_work_func_t func)
{
twork->func = func;
- twork->data = data;
}
int task_work_add(struct task_struct *task, struct task_work *twork, bool);
sched_setscheduler(current, SCHED_FIFO, ¶m);
- init_task_work(&on_exit_work, irq_thread_dtor, NULL);
+ init_task_work(&on_exit_work, irq_thread_dtor);
task_work_add(current, &on_exit_work, false);
while (!irq_wait_for_interrupt(action)) {
#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);
{
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;
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;
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();
/* 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;
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;