Re: [PATCH] kthread: fix use-after-free if kthread fork fails

2017-05-06 Thread Oleg Nesterov
On 05/05, Vegard Nossum wrote: > > On 05/05/17 18:44, Oleg Nesterov wrote: > > > >Can't we just move both > > > > p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : > > NULL; > > /* > > * Clear TID on mm_release()? > > */ > > p->clear_child_tid = (clone_fl

Re: [PATCH] kthread: fix use-after-free if kthread fork fails

2017-05-05 Thread Vegard Nossum
On 05/05/17 18:44, Oleg Nesterov wrote: On 05/05, Vegard Nossum wrote: 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 par

Re: [PATCH] kthread: fix use-after-free if kthread fork fails

2017-05-05 Thread Oleg Nesterov
On 05/05, Vegard Nossum wrote: > > 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 f

[PATCH] kthread: fix use-after-free if kthread fork fails

2017-05-05 Thread Vegard Nossum
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()