Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3958974ybf; Tue, 3 Mar 2020 16:44:10 -0800 (PST) X-Google-Smtp-Source: ADFU+vul69SfoadaJh8CQFcptwYQKSFq9kD0NNCz2PnYJbvlZnh/OGZ9Ml1Wa/6h5CYPwvlI94LD X-Received: by 2002:a05:6830:4a6:: with SMTP id l6mr454411otd.61.1583282650319; Tue, 03 Mar 2020 16:44:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583282650; cv=none; d=google.com; s=arc-20160816; b=EUPt7nRdSQimgffwMWCwBdSXMuRT8Os37GAw9y+v7htJjW4sMBYTV+g+dllN43YMND Lj0ECvzmZcP9cPR9xiqtFjMf6LKM5amhzKKAOuvWtRa+XN0kJOzkYQEHx2nkf4CvZOLT szoPzhdVaovJTS2bGaO2KCxsoLuKQmJBzN7Mm4lJp5+9bRsZdn67sI7drYl6ZyJy8LfT xpg3Rg075kNxMaW+wTleDR5dETh++40EGw6PweMNsWdI+zfkDeGQdyJQ37HgDg6jrn1X 05tRuv2XdH+r4WieL25OLnGBCTfY2CMbk6zv/MpI3Sm+VzjCoPubT74ma5bDFru9bQ57 +c0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DRZPjOU86C+QBTaOB6DsJlZhFthqBDzzJfXy4mDxK2E=; b=jWrGN5d834zotKe3IIigz46m3EeNnxlZVxX6SIJ6IU9571683AKSHoTGgbdOQF923i tNy9z1jP/JuxA4tzjZT0Z89sbCw3rBp6obTHKRw0wX0rpTjBL9Fajw+0pTP2dGY3EnGs sCfB1QgkyfbCzA5eAqfQ/fVJlH4BJjBK17MxgWhI84pGQ0y/kbmLwXCzIXGLJrsBT0uI 9lpdkiJhc3RxLKM/NG4LVjtGWsbMhJoPsCXeQ4KRcZmW+zHZ8BTe6NHi/R4Bp73NvYpO FuzLI8d4UBqdl6vfVo5xGkbxTOnqTyppIYKfjy9iPD9dfwPVgqfy1gBfbsU+cdHkVmYp D8dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=J5dJtf5o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21si160253otk.196.2020.03.03.16.43.58; Tue, 03 Mar 2020 16:44:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=J5dJtf5o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387419AbgCDAnr (ORCPT + 99 others); Tue, 3 Mar 2020 19:43:47 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:36952 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387396AbgCDAnq (ORCPT ); Tue, 3 Mar 2020 19:43:46 -0500 Received: by mail-qk1-f196.google.com with SMTP id m9so5454333qke.4 for ; Tue, 03 Mar 2020 16:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DRZPjOU86C+QBTaOB6DsJlZhFthqBDzzJfXy4mDxK2E=; b=J5dJtf5oYmzUXexSyHe+zHPOgeJmiMlpBKHCOi4i4YYu4dpJRn+Pbu450LBkIBtNDJ uyNQlkVBnAyZQ6CvoXptBQSCXSwVGZq1GSk1YYKrIkaBLFe/fV5jlamq7cMbwKQlJojW S/lAP4inVw4lAR88C4BzNgptPwd3Kq53+D/WrM3nPrKh5cEoc2BSIIpNIs1tnRQnYUD6 aqSv/l34Gtn3NsWHJapV8yGVO5MDmf5rGMtsD5LevkFpQP14UdWwJrrWKKEJZzFq8nFp XfZCrFT1+/5SJvnYSr0cMI9opufqhxEUqeX9yzoP9BSyqRmRTHRraCHGzWCfPMwMlOq4 g0vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DRZPjOU86C+QBTaOB6DsJlZhFthqBDzzJfXy4mDxK2E=; b=sgiyFDwebqHAcVzBgzCbA6m84Ui6unzpEl71J6WBFVaYGVuw5gaRRu8hftO8hdk37Y f+kKfXWQ49i0On1FJ98zpbMfgRs9BKGrOnRVXjbOc2qNzAnQuzoWOtJf1YIfAK57MdRB 3s2nhFKtvFpmWW7glohFgyVTwr5Qw5fd77Ba+T+s2m2RfzRX9VQdSiSAkBELqRH1rfr9 6fzdAOFifhiC2oOcO1ydLRg5n7UVRt8l3mZZu/H8sXA3WgB6ajUx6S5gYc8JgiDbGTmO QDl8drv7v3EKGqNeB2ucX2quIlypSVMRX0MH0P1NJ/23A79o1Dl7BrTC2813+OXocMZN FDCw== X-Gm-Message-State: ANhLgQ0GMXMSg5vLGIcLVSc6001wxiFe69KvqoxieXVMjaVr5cF8+ytq BtNHo4kQONmL/53xKa1KRnsfOyvzJd07OQ== X-Received: by 2002:a05:620a:806:: with SMTP id s6mr664391qks.235.1583282625401; Tue, 03 Mar 2020 16:43:45 -0800 (PST) Received: from ovpn-121-139.rdu2.redhat.com (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id w48sm14038759qtc.40.2020.03.03.16.43.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 16:43:44 -0800 (PST) From: Qian Cai To: tglx@linutronix.de Cc: ebiederm@xmission.com, oleg@redhat.com, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH -next] posix-cpu-timers: fix memory leaks for task_struct Date: Tue, 3 Mar 2020 19:43:36 -0500 Message-Id: <20200304004336.960-1-cai@lca.pw> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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)