lkml.org 
[lkml]   [2020]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH timers/core] posix-cpu-timers: Put the task_struct in posix_cpu_timers_create
Thomas Gleixner <tglx@linutronix.de> writes:

> ebiederm@xmission.com (Eric W. Biederman) writes:
>
>> Qian Cai <cai@lca.pw> writes:
>>> The recent commit removed put_task_struct() in posix_cpu_timer_del()
>>> results in many memory leaks like this,
>>>
>>> unreferenced object 0xc0000016d9b44480 (size 8192):
>>> comm "timer_create01", pid 57749, jiffies 4295163733 (age 6159.670s)
>>> hex dump (first 32 bytes):
>>> 02 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ................
>>> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
>>> backtrace:
>>> [<0000000056aca129>] copy_process+0x26c/0x18e0
>>> alloc_task_struct_node at kernel/fork.c:169
>>> (inlined by) dup_task_struct at kernel/fork.c:877
>>> (inlined by) copy_process at kernel/fork.c:1929
>>> [<00000000bdbbf9f8>] _do_fork+0xac/0xb20
>>> [<00000000dcb1c445>] __do_sys_clone+0x98/0xe0
>>> __do_sys_clone at kernel/fork.c:2591
>>> [<000000006c059205>] ppc_clone+0x8/0xc
>>> ppc_clone at arch/powerpc/kernel/entry_64.S:479
>>>
>>
>> I forgot that get_task_for_clock called by posix_cpu_timer_create
>> returns a reference to a task_struct. Put that reference
>> to avoid the leak.
>
> I took the liberty to fold this back into the affected commit and add a
> comment why this put_task_struct() is actually required.

Good enough.

We should be able to use rcu and remove the reference entirely.
But that is a change for another day.

Eric

\
 
 \ /
  Last update: 2020-03-04 15:36    [W:0.034 / U:46.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site