Received: by 10.223.185.116 with SMTP id b49csp2553093wrg; Mon, 12 Feb 2018 11:27:38 -0800 (PST) X-Google-Smtp-Source: AH8x225LKlZunwCA/y75QHeyYoNu7HvIL4iMSFBK94IEskdQKnCyKmqMvS6S4s7U8SF/nxojK8Vc X-Received: by 10.98.242.14 with SMTP id m14mr7326163pfh.230.1518463657890; Mon, 12 Feb 2018 11:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518463657; cv=none; d=google.com; s=arc-20160816; b=HNF+C0Qeh58ZEXI/Rugs4lpclbeOFDquJReqbMjeu7IhPsv5VVfuFlkEnxzCgFUcfd XTvn60xWe3JASspqaThnqU7Lu48oHf4E8tg5lkHzF8NwtPcU6OrHrmZGyVlmFvCs/d+3 PYmk/JQbSI6/lQogAeFfABbGxS3PXPciHP6R/abhnihWIuhAkX3r0FQO6Mi+h5m7tqPj m0jvD5M0fueT4YXFXItYBLcrGENS2Um4Ddr1Lkq8diDU4zCoExUM21Df0EPdHaLy9reN +WThWM9oQaXGroMaO4wxyqZFP7r3qV1JSnnigt7xx47xQw/v45EWYvvBrFilYbl/gF69 if+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=pzFmfF7mYhCKclySz/a1jtUYlPzHSiRF6W0UuEklVVM=; b=w6xEvuEC3rGiEwinpnk8BjqIGG2mqJgX4MO5YDLtsmNMWFNjx/U5VDF9Vmh4GWNAfW McWXjWxjSRKENH2W3ux5Y3qfXSVsX1SvOXIThZnqopFtRZY8TDXa+t8uslVmUW/zN9qf xDnekJedpbMh9escy2QJQYMF/8xih6zZPmpliWTdJ1L/0qgl6F6Gzi2ZVMCzbycemGSH FLSl2LXsIaka2ncB1xjpN8NMzfXRh7guhwpppCQlLD1A9Ocj5VWiRJpjEakHXId9nU1Y v3RsplTD+0EEBBOuJhvqlDvYVp6LwgGsiwGd+mcej7TGFvaKiPbIa4iNq5a3lfrZG0po uRTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=S28qGtf0; 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 d15si2526186pgv.822.2018.02.12.11.27.22; Mon, 12 Feb 2018 11:27:37 -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=fail header.i=@gmail.com header.s=20161025 header.b=S28qGtf0; 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 S1751041AbeBLT0i (ORCPT + 99 others); Mon, 12 Feb 2018 14:26:38 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:40221 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750785AbeBLT0g (ORCPT ); Mon, 12 Feb 2018 14:26:36 -0500 Received: by mail-ua0-f196.google.com with SMTP id t6so10132971ual.7 for ; Mon, 12 Feb 2018 11:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=pzFmfF7mYhCKclySz/a1jtUYlPzHSiRF6W0UuEklVVM=; b=S28qGtf0axDcjhg3DdW3QNaFUwCI0B30fmjQgzpaY/TDDtOMIEeozioG9Ra8avWslW 4s3FJrGkKdBDHRqBNxqPUUX8csLW+SYvdvMitKzK1AyeLgDhHif2tOF8haeOwRT6eKjD S3puU7KAG3N/qU/XjTxSRjxn6YKge2ABgVbsJzumIWs2pwL9GoPgQg/Qc3kGl8e/+45w ruhAccgqYehBdC7GXDC4zYheJLXrZ/ZhCEEbbSjRkNk52+5cng4Yc0JybLnOEkSX0bRC yDVMD/8IN3pkGf7XAMeu3k5wem7cgPFiulO0QcOjO/QeQToBihAaQgnIn2PwXnzbtPd8 C5gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=pzFmfF7mYhCKclySz/a1jtUYlPzHSiRF6W0UuEklVVM=; b=czfYGnNo/kzZgSZRogrcFNToGrmtmHdQgHKTUeqzYPSG5GNVJn6itq/QvN3mCQnkyn RhhRoNedc+Q+P0Y28jKT1n2YVuwpr621FP8L8+apaVdaSWg3S0wLt3DW9OUYjNVnLMrO kbey9eIkeAJ33do8zjqpQd7W3mn+80nrj5Ohsc1JXS49P27PnG1zR0GBjigvYWjus0/D 2zCPF0XpNgVLN3KprxHMLL3Ow68IVMBOUVwXk5Ro+kOCj+PQsuN9N4zAs2HRrCaGqoRb HJ0fWad52pAjNLAksmDXz9lzlG9Spg9o8yBMtRRoWH9hD801jXcQ2cGjq4K7XJsDZxYo xMTg== X-Gm-Message-State: APf1xPAy3r0r7Gut2MvIAJwkatLab5a1LNpEvXTwVWismXfsh9kMSwEz SSHcWNAevOuGMxVus4/dewY9Hr34r29FPPHBBq6pLw== X-Received: by 10.159.54.82 with SMTP id s18mr11170203uad.57.1518463595929; Mon, 12 Feb 2018 11:26:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.38.193 with HTTP; Mon, 12 Feb 2018 11:26:15 -0800 (PST) In-Reply-To: <3fa5958d-c14e-56bd-de49-84fc43db4b32@fb.com> References: <3fa5958d-c14e-56bd-de49-84fc43db4b32@fb.com> From: Mathieu Malaterre Date: Mon, 12 Feb 2018 20:26:15 +0100 X-Google-Sender-Auth: AT9gVV-_soivltjW3uxuOQqhh_4 Message-ID: Subject: Re: [kmemleak] unreferenced object 0xcd9c1a80 (size 192): To: Yonghong Song Cc: Alexei Starovoitov , Alexei Starovoitov , Daniel Borkmann , LKML Content-Type: text/plain; charset="UTF-8" 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 6:47 AM, Yonghong Song wrote: > > > On 2/11/18 11:18 AM, Mathieu Malaterre wrote: >> >> Hi, >> >> 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); > } > > static int trie_get_next_key(struct bpf_map *map, void *_key, void > *_next_key) > -bash-4.2$ With this single patch added, system has been running for a couple of hours, no memleak reported. So: Tested-by: Mathieu Malaterre > Will propose a formal patch for this soon. Will retest if needed. Thanks ! -M