Received: by 10.223.185.116 with SMTP id b49csp2398757wrg; Mon, 12 Feb 2018 08:57:18 -0800 (PST) X-Google-Smtp-Source: AH8x227/JSL+xmKa3qIQbqGNHnfL+WWF3bQJZNcCOSBARJbpQQ1hWPfJhjuHWe2diVEQrmV8+1cJ X-Received: by 10.98.49.7 with SMTP id x7mr9106106pfx.101.1518454638009; Mon, 12 Feb 2018 08:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518454637; cv=none; d=google.com; s=arc-20160816; b=UkH9bXr0PNguH6pw5TjtTZUyQGqjQIJu4Ui/9PRCVdQ26Z6bC0Kyxh6PkAwODh+OpC aUsU3FDHZowAbKTUqYzOJvJYWUwVo1rfCbgIyfvj7b00+Z/aZFrUybHpR6uDT0mQWWU9 RqWB8ECXxllac8IwrDY1Te7njK8NR8ZpIstawKlTr/IvLkSyukJIQhAAsoKJq95aqU/w QXS1CcDiIT/i3oJMDijdzOmFad+5mnF0QOFiZDRxT8Wv7/eTDJxWz6poIn5BvBiXHjxO xczTiR6pMIZwEv7LLeHLTPaj+7vcB+wDCguM+dHx/9F+ivuzqLpAere7ZtKWJY0P+Srt 0Kxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=9Z3QVzhY7Ui256YGjWRC4fRzIdQtjDjUPzP+QwpOOJw=; b=OdgvYfFSowCIbKR2324q9DINg1RXIgu6sxZi7vl860A9q4duQjyVCmewBNcKYXOWzk gG7xYRCvhGzInn2x/sPFGkiSQU/y5F3TNRyxlupP4i0/Kjxk1rPhtin//vzqzl8enUVe Kr0STXH7qf7HEGXxZegL45xkuXykzjwTedetLMnKr/rV+R4xxKNjr0m9dF/yEPMuwV6r FrDiPLhlr0WgT8irlrBZa0U5vKBxL2hhWrOICXacv8GYNSNwYWdiLIfXDMC1aVLn/oG2 4K0n41xuCTGjF8VGNbSNYArMOJpP9mFfleb8JRZHwQN3fDeuf+gC2j1pSEuWFJ8t+WuK uPXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JjCJfwKE; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si816012plh.41.2018.02.12.08.57.03; Mon, 12 Feb 2018 08:57: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JjCJfwKE; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934409AbeBLP4S (ORCPT + 99 others); Mon, 12 Feb 2018 10:56:18 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:46159 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933935AbeBLP4C (ORCPT ); Mon, 12 Feb 2018 10:56:02 -0500 Received: by mail-pl0-f67.google.com with SMTP id x2so1195938plr.13 for ; Mon, 12 Feb 2018 07:56:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=9Z3QVzhY7Ui256YGjWRC4fRzIdQtjDjUPzP+QwpOOJw=; b=JjCJfwKENCMhx0kSsMi3m0yElHbzbmgf+6AmDiEknsOO+szemjw5bc56opKfmbvP7U w0ZJ/1MBMiMCetDIr2nYZpPLGwpGsZch2Q6Uu1MTUvYKhC13D9/AyArM3BZOSfJt3WME hsbLiwrHX5cg8Im9jgSFrSzTREuOcGi8OBjL0TzBlAqsejdK9v/JEga9wjaTZY4uH6vD PaB0bYcv7CfTzuoFQBIHUUJXkjoy7/9WeraQa6sF003nlkChml1XIbXQMfJOOEreqo/i MKpiRZ1TVf20H1zYyD3jtGxGWNZqeAxJkRwIQdC4xi9xLwiuJDXNp7i6w2F3cuhcOwP3 pqYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=9Z3QVzhY7Ui256YGjWRC4fRzIdQtjDjUPzP+QwpOOJw=; b=dXyN8zAGGN3LtSMh5amk8p/nAyY70evqIFWOD2ykPJk5ec+NzjN6NS8rrepPhhVO8l FrkjD9xu1w7FTJfX1n5MZnp3JfYpI4qOFgcRfxKzJXmHXWekkHPMCE6du2kMXJuyypMx 5iYTX0RnPet3wr+bvuj9N9C5F9lwkSo+VoEAsVia5+oDwiM68JDsRfgEWObUkizqI3Dr kvkezrIZQlIfC7pi3QXzvE5KWG3GlS3tK2x2zKW0/4N/s8nwGFwL0pMKQamFi7gR+qJw 1CvsmXiXQYq1/mxUs8B7+cZbeBor9IBJxhkRJBm3v9z8OJ6dMIFx5I+RwCWg6Ol/O8Mp MyVQ== X-Gm-Message-State: APf1xPAzykwjaybs9KrEsk4Iqr24z2mbtO7T5IGlxS/WbX1N8DmRNx/m yNxZTBcKoSbUDTZ7ilqTdlA= X-Received: by 2002:a17:902:be09:: with SMTP id r9-v6mr11167512pls.234.1518450961507; Mon, 12 Feb 2018 07:56:01 -0800 (PST) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:200::7:1289]) by smtp.gmail.com with ESMTPSA id 205sm25126402pfw.77.2018.02.12.07.55.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Feb 2018 07:56:00 -0800 (PST) Date: Mon, 12 Feb 2018 07:55:58 -0800 From: Alexei Starovoitov To: Daniel Borkmann Cc: Yonghong Song , Mathieu Malaterre , Alexei Starovoitov , LKML Subject: Re: [kmemleak] unreferenced object 0xcd9c1a80 (size 192): Message-ID: <20180212155556.5glgl6qorvuwvubs@ast-mbp.dhcp.thefacebook.com> References: <3fa5958d-c14e-56bd-de49-84fc43db4b32@fb.com> <609d04c4-f947-ede5-3c4f-28eaf0b14745@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <609d04c4-f947-ede5-3c4f-28eaf0b14745@iogearbox.net> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 12, 2018 at 09:28:33AM +0100, Daniel Borkmann wrote: > On 02/12/2018 06:47 AM, Yonghong Song wrote: > > On 2/11/18 11:18 AM, Mathieu Malaterre wrote: > >> On Sun, Feb 11, 2018 at 5:54 PM, Alexei Starovoitov > >> wrote: > >>> On Sun, Feb 11, 2018 at 7:24 AM, Mathieu Malaterre wrote: > >>>> Alexei, > >>>> > >>>> Could you please comment on why I am seeing those memleaks being > >>>> reported on my ppc32 system ? Should they be marked as false positive > >>>> ? > >>>> > >>>> System is Mac Mini G4, git/master (4.15.0+), ppc. > >>>> > >>>> Thanks for your time > >>>> > >>>> $ dmesg > >>>> ... > >>>> [ 1281.504173] kmemleak: 36 new suspected memory leaks (see > >>>> /sys/kernel/debug/kmemleak) > >>>> > >>>> Where: > >>>> > >>>> # cat /sys/kernel/debug/kmemleak > >>>> unreferenced object 0xdee25000 (size 192): > >>>> ?? comm "systemd", pid 1, jiffies 4294894348 (age 1438.580s) > >>>> ?? hex dump (first 32 bytes): > >>>> ???? c0 56 2f 88 00 00 00 00 00 00 00 0b 00 00 00 0c? .V/............. > >>>> ???? 00 00 00 08 00 00 00 01 00 00 00 01 00 00 00 01? ................ > >>>> ?? backtrace: > >>>> ???? [<6c69baf5>] trie_alloc+0xb0/0x150 > >>>> ???? [] SyS_bpf+0x288/0x1458 > >>>> ???? [<82182f53>] ret_from_syscall+0x0/0x38 > >>>> unreferenced object 0xdee25900 (size 192): > >>>> ?? comm "systemd", pid 1, jiffies 4294894540 (age 1437.812s) > >>>> ?? hex dump (first 32 bytes): > >>>> ???? c0 56 2f 88 00 00 00 00 00 00 00 0b 00 00 00 08? .V/............. > >>>> ???? 00 00 00 08 00 00 00 01 00 00 00 01 00 00 00 01? ................ > >>>> ?? backtrace: > >>>> ???? [<6c69baf5>] trie_alloc+0xb0/0x150 > >>>> ???? [] SyS_bpf+0x288/0x1458 > >>>> ???? [<82182f53>] ret_from_syscall+0x0/0x38 > >>> > >>> hmm. looks real. Is there a reproducer? > >>> Yonghong, lpm map not cleaning after itself? > >> > >> Not really. I simply boot up my machine and wait for the first kmemleak scan. > > > > I am not able to reproduce the issue. Tried with latest net-next on FC26 with kmemleak on. I only got this one after bootup, > > 'cat /sys/kernel/debug/kmemleak' or > > 'echo scan > /sys/kernel/debug/kmemleak > > ?cat /sys/kernel/debug/kmemleak': > > > > unreferenced object 0xffff99701a7386e0 (size 32): > > ? comm "mount", pid 1856, jiffies 4294669263 (age 98.440s) > > ? hex dump (first 32 bytes): > > ??? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00? ................ > > ??? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00? ................ > > ? backtrace: > > ??? [<000000004668ec00>] security_sb_parse_opts_str+0x36/0x50 > > ??? [<00000000a9807d2b>] parse_security_options+0x3d/0x60 > > ??? [<00000000cc1e1d58>] btrfs_mount_root+0x139/0x720 > > ??? [<00000000bdc4f1a3>] mount_fs+0x30/0x150 > > ??? [<00000000f189f1bd>] vfs_kern_mount.part.26+0x54/0x100 > > ??? [<0000000093ae5db7>] btrfs_mount+0x184/0x914 > > ??? [<00000000bdc4f1a3>] mount_fs+0x30/0x150 > > ??? [<00000000f189f1bd>] vfs_kern_mount.part.26+0x54/0x100 > > ??? [<000000003b67b9fc>] do_mount+0x5b9/0xc70 > > ??? [<00000000de4073a0>] SyS_mount+0x80/0xd0 > > ??? [<00000000fc5a968a>] do_syscall_64+0x5d/0x110 > > ??? [<000000003d61f5fc>] entry_SYSCALL_64_after_hwframe+0x21/0x86 > > ??? [<00000000458a6ffa>] 0xffffffffffffffff > > > > Not sure whether the above is a true issue or not. > > > > However, by inspecting the code, I do find the trie_free in lpm_trie.c > > may have missed freeing the trie memory. > > > > The change likes below should work: > > -bash-4.2$ git diff > > diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c > > index 7b469d1..cecb259 100644 > > --- a/kernel/bpf/lpm_trie.c > > +++ b/kernel/bpf/lpm_trie.c > > @@ -589,6 +589,7 @@ static void trie_free(struct bpf_map *map) > > > > ?unlock: > > ??????? raw_spin_unlock(&trie->lock); > > +?????? kfree(trie); also looks like trie_free() is missing synchronize_rcu() + rcu_barrier() it doesn't wait for parallel lookup/update/delete to complete before freeing the elements.