All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] posix-cpu-timers: fix memory leaks for task_struct
@ 2020-03-04  0:43 Qian Cai
  2020-03-04  5:15 ` Eric W. Biederman
  2020-03-04  5:21 ` [PATCH timers/core] posix-cpu-timers: Put the task_struct in posix_cpu_timers_create Eric W. Biederman
  0 siblings, 2 replies; 5+ messages in thread
From: Qian Cai @ 2020-03-04  0:43 UTC (permalink / raw)
  To: tglx; +Cc: ebiederm, oleg, linux-kernel, Qian Cai

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

Fixes: 672ebe8eb017a5 ("posix-cpu-timers: Store a reference to a pid not a task")
Signed-off-by: Qian Cai <cai@lca.pw>
---
 kernel/time/posix-cpu-timers.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index afd1e959a282..e0b580deb61a 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -446,8 +446,10 @@ static int posix_cpu_timer_del(struct k_itimer *timer)
 
 out:
 	rcu_read_unlock();
-	if (!ret)
+	if (!ret) {
 		put_pid(ctmr->pid);
+		put_task_struct(p);
+	}
 
 	return ret;
 }
-- 
2.21.0 (Apple Git-122.2)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-04 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04  0:43 [PATCH -next] posix-cpu-timers: fix memory leaks for task_struct Qian Cai
2020-03-04  5:15 ` Eric W. Biederman
2020-03-04  5:21 ` [PATCH timers/core] posix-cpu-timers: Put the task_struct in posix_cpu_timers_create Eric W. Biederman
2020-03-04  8:56   ` Thomas Gleixner
2020-03-04 14:32     ` Eric W. Biederman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.