Received: by 10.223.164.202 with SMTP id h10csp268589wrb; Tue, 14 Nov 2017 22:34:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ0x2msNBMLbTM7yu2xehFg7ySckiLkmUzXHxOKgoo+blq0UkmV09ftynB10YcsR4AZvOx6 X-Received: by 10.101.75.14 with SMTP id r14mr14935937pgq.232.1510727657840; Tue, 14 Nov 2017 22:34:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510727657; cv=none; d=google.com; s=arc-20160816; b=uyZ0TA9QP2N2uNm7GV/RewtjTb6qSegsUCSHo7kHP3h6VJnMsXqGzZq+6V25eR215t aa4aWd1/lpnrLo9zV7wg3J6koTSLcuP+Ij72pU2gRKp9AT0zzkTv7ugr000p6FETTOEy Y98BCq9D46e/rgSsKeAKgzEzuh490tzfN7IxTCh6HXzNX2NNOPErEbw7wo08t1Wlw+VH uStD3DUoAk8ml5j2/8P2hwh83UDinzbI942xkDBoDG2VllTALZ1nokBOxt0t6FFtgaau aSIRuYZks+7kPi/mYq4h6gq+rCDzrWHSc+cN0bXphyAX6VIdgmQXkpQJVjc8f7WfjnQk wgrA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=YQxRMrdPKaMM0ZCjSat4mwMQEAlG/46A+2QCrOpjGJg=; b=ySR0wN6TK8Y5AaISQAjNaLH2U/MFqkw3kfzusLSBDaIXJsqAxNK0TB8mx/pqpKuaWi uC4RgVFvfX7gTx2DsJjTKhijIb9EqZVR0AU2MRE+Ix159PfJoPyx17RRA44G7xw+3vft T3t72fjCtBAyJ7IzHlsNpxrIv7m09X+4c/ETMa25JUt+uFVuHZoeJ2o9vXAvJ261iM6V EhD2ZXTvpCKqBQ3Gg7KGbmfFwrQQG32PIaWPAs3nnCNn39jQ2ZL41JQWsjRTYM0vZI2Z P8t2WWn2TBXzcUZKqa0ghCjsuCtUY0dxI+J8r+eDlg4ywZ+0I+VJH2i2dryV4dNKFbZS 3qjA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n189si16822304pga.205.2017.11.14.22.34.05; Tue, 14 Nov 2017 22:34:17 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757156AbdKOFsr (ORCPT + 88 others); Wed, 15 Nov 2017 00:48:47 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:45497 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756973AbdKOFsk (ORCPT ); Wed, 15 Nov 2017 00:48:40 -0500 Received: from [172.16.24.21] (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id vAF5mcXS005511; Wed, 15 Nov 2017 08:48:38 +0300 (MSK) Subject: Re: [PATCH] lost path_put in perf_fill_ns_link_info To: Alexander Shishkin Cc: linux-kernel@vger.kernel.org, Hari Bathini , Namhyung Kim , Jiri Olsa , Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra References: <20171108120915.n7i46j2yly6fb7bj@ukko.fi.intel.com> <2d0707fa-7265-8b82-23a0-b3a938111767@virtuozzo.com> From: Vasily Averin Message-ID: <9e5342b4-ab66-dadb-4cff-0ec73502cd67@virtuozzo.com> Date: Wed, 15 Nov 2017 08:48:38 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <2d0707fa-7265-8b82-23a0-b3a938111767@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017-11-08 16:04, Vasily Averin wrote: > On 2017-11-08 15:09, Alexander Shishkin wrote: >> On Mon, Nov 06, 2017 at 09:22:18AM +0300, Vasily Averin wrote: >>> Fixes: commit e422267322cd ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info") >>> Signed-off-by: Vasily Averin >> >> The change description is missing. One needs to open the source code and >> look for proof of correctness for this patch. > > perf_fill_ns_link_info() calls ns_get_path() > it returns ns_path with increased mnt and dentry counters. > > Problem is that nodody decrement these counters. > > You can call ./perf record --namespaces unshare -m > and look how grows mount counter on nsfs_mnt. Situation is even worse, leaked dentry does not allow to free related namespaces. [root@localhost ~]# uname -a Linux localhost.localdomain 4.14.0+ #10 SMP Wed Nov 15 00:31:34 MSK 2017 x86_64 x86_64 x86_64 GNU/Linux VvS: without --namespace perf works correctly [root@localhost ~]# grep namespace /proc/slabinfo pid_namespace 0 0 2568 12 8 : tunables 0 0 0 : slabdata 0 0 0 user_namespace 0 0 824 39 8 : tunables 0 0 0 : slabdata 0 0 0 net_namespace 0 5 6272 5 8 : tunables 0 0 0 : slabdata 1 1 0 [root@localhost ~]# perf record -q unshare -n -U -p --fork true [root@localhost ~]# grep namespace /proc/slabinfo pid_namespace 0 12 2568 12 8 : tunables 0 0 0 : slabdata 1 1 0 user_namespace 0 39 824 39 8 : tunables 0 0 0 : slabdata 1 1 0 net_namespace 0 5 6272 5 8 : tunables 0 0 0 : slabdata 1 1 0 VvS: with --namespace perf leaks namespaces [root@localhost ~]# perf record -q --namespace unshare -n -U -p --fork true [root@localhost ~]# grep namespace /proc/slabinfo pid_namespace 1 12 2568 12 8 : tunables 0 0 0 : slabdata 1 1 0 user_namespace 1 39 824 39 8 : tunables 0 0 0 : slabdata 1 1 0 net_namespace 1 5 6272 5 8 : tunables 0 0 0 : slabdata 1 1 0 VvS: ... and once again, to be sure [root@localhost ~]# perf record -q --namespace unshare -n -U -p --fork true [root@localhost ~]# grep namespace /proc/slabinfo pid_namespace 2 12 2568 12 8 : tunables 0 0 0 : slabdata 1 1 0 user_namespace 2 39 824 39 8 : tunables 0 0 0 : slabdata 1 1 0 net_namespace 2 5 6272 5 8 : tunables 0 0 0 : slabdata 1 1 0 kmemleak also detects leaks dentry, inode, related structures and namespaces unreferenced object 0xffff998008e76738 (size 192): <<< dentry comm "unshare", pid 1436, jiffies 4294786539 (age 509.114s) [] __ns_get_path+0xf5/0x160 [] ns_get_path+0x28/0x50 [] perf_fill_ns_link_info+0x20/0x80 [] perf_event_namespaces.part.101+0xd7/0x120 [] copy_process.part.34+0x171d/0x1ae0 [] _do_fork+0xcc/0x390 [] do_syscall_64+0x61/0x170 [] return_from_SYSCALL_64+0x0/0x65 [] 0xffffffffffffffff unreferenced object 0xffff998008e7c928 (size 600): <<< inode comm "unshare", pid 1436, jiffies 4294786539 (age 509.114s) [] new_inode_pseudo+0xe/0x60 [] __ns_get_path+0x42/0x160 [] ns_get_path+0x28/0x50 ... unreferenced object 0xffff99800cacd320 (size 40): <<< inode_security_struct comm "unshare", pid 1436, jiffies 4294786539 (age 509.114s) [] security_inode_alloc+0x36/0x50 [] inode_init_always+0xf5/0x1d0 [] alloc_inode+0x2b/0x80 [] new_inode_pseudo+0xe/0x60 [] __ns_get_path+0x42/0x160 ... unreferenced object 0xffff99800cb88a10 (size 2232): <<< pid_namespace comm "unshare", pid 1436, jiffies 4294786439 (age 509.214s) [] create_new_namespaces+0xd4/0x1b0 [] unshare_nsproxy_namespaces+0x59/0xb0 [] SyS_unshare+0x1e5/0x370 [] entry_SYSCALL_64_fastpath+0x1a/0x7d [] 0xffffffffffffffff I've resend the patch as "[PATCH] memory leaks triggered by perf --namespace" Thank you, Vasily Averin From 1583503302808167863@xxx Wed Nov 08 13:07:09 +0000 2017 X-GM-THRID: 1583296720926435526 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread