aboutsummaryrefslogtreecommitdiff
path: root/lib/test-string_helpers.c
diff options
context:
space:
mode:
authorVegard Nossum <[email protected]>2017-05-09 09:39:59 +0200
committerThomas Gleixner <[email protected]>2017-05-22 22:21:16 +0200
commit4d6501dce079c1eb6bf0b1d8f528a5e81770109e (patch)
tree652f4e0fccb85573bde0ada8e74c15ff0295fb3f /lib/test-string_helpers.c
parent5ea30e4e58040cfd6434c2f33dc3ea76e2c15b05 (diff)
kthread: Fix use-after-free if kthread fork fails
If a kthread forks (e.g. usermodehelper since commit 1da5c46fa965) but fails in copy_process() between calling dup_task_struct() and setting p->set_child_tid, then the value of p->set_child_tid will be inherited from the parent and get prematurely freed by free_kthread_struct(). kthread() - worker_thread() - process_one_work() | - call_usermodehelper_exec_work() | - kernel_thread() | - _do_fork() | - copy_process() | - dup_task_struct() | - arch_dup_task_struct() | - tsk->set_child_tid = current->set_child_tid // implied | - ... | - goto bad_fork_* | - ... | - free_task(tsk) | - free_kthread_struct(tsk) | - kfree(tsk->set_child_tid) - ... - schedule() - __schedule() - wq_worker_sleeping() - kthread_data(task)->flags // UAF The problem started showing up with commit 1da5c46fa965 since it reused ->set_child_tid for the kthread worker data. A better long-term solution might be to get rid of the ->set_child_tid abuse. The comment in set_kthread_struct() also looks slightly wrong. Debugged-by: Jamie Iles <[email protected]> Fixes: 1da5c46fa965 ("kthread: Make struct kthread kmalloc'ed") Signed-off-by: Vegard Nossum <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jamie Iles <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
Diffstat (limited to 'lib/test-string_helpers.c')
0 files changed, 0 insertions, 0 deletions