Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp927305pxb; Wed, 3 Mar 2021 21:20:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFV6OvJvsIXxGswhYx2XniPmZ+bHBVHja10w8H3QGBcQwzvyvTz6bDL3Ln0rhbKscekn1+ X-Received: by 2002:a05:6402:350f:: with SMTP id b15mr2497966edd.6.1614835246084; Wed, 03 Mar 2021 21:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614835246; cv=none; d=google.com; s=arc-20160816; b=eBichS6h78pTe/fMtc9GFktL2PmFMuuuSFQtAIYkUSmj//9CDy6DbgHBH+2v86Bu6N nUPtU8O7gSzpKynkN4AexsUvxCQIpAkCjMNH2F83O86C6VQN200ka2e0X2EbKmda2Fj8 r+1CQ3/KyCL+qy15oKYGc8tvXR6Uy18zcv9Qpib9N9I1EiG/7U+SuAV6caP8qgnBXc7i eRZ0JlJ4kODIeAvZRKcU/zC9U+3aodJDS2cE2GGG7tkw1GZbOiSbT1orBNBT/ftCCYqI Hu/pXOn7iEkTw9zjZYuOAtGKhLrOSRwEOH9mL5zqpyDTZGpLFYQTWC5OSp7TwUVTKCcn rkHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9aJvPPQuZOpMY5U+SSFHkmCbcWziEboEri+b50pt18s=; b=gWRpAFfHHmKuKI1uwBc53lk8gOY8y04X9cE86jCJqU/CFbCO34snIjFKlqunsBx4xV uZHisiI2+MUvCt8io8uLZxm+KR1zw2QmG5+z1soSWZQZ8i7l3vku47BGO8X72iTGWGKJ gjfKpiG6sb86GRUnpRxIyDl+7TIdncNBzCh4/Qu/Rw8YzhCaDAB2cEKlPZUtj1FfRuXx Y2zHB7zeFZy7n4sYySdsAHIXs5FIxjKm5ejxDsLlD8mLHqoams8F+WpuOuI6Zlo/DAT5 yaQG/btbpRZXb76u/jIw3y6sMM9Q/2Vbr4XRxYAmaaXBRS4qFZfsOY+wUmK2keTsLabI s04A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Foc7dKiK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id jl2si11248693ejc.488.2021.03.03.21.20.23; Wed, 03 Mar 2021 21:20:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Foc7dKiK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1574122AbhCBD3P (ORCPT + 99 others); Mon, 1 Mar 2021 22:29:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240317AbhCAUkg (ORCPT ); Mon, 1 Mar 2021 15:40:36 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACD47C061756; Mon, 1 Mar 2021 12:39:55 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id i14so357829pjz.4; Mon, 01 Mar 2021 12:39:55 -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:in-reply-to; bh=9aJvPPQuZOpMY5U+SSFHkmCbcWziEboEri+b50pt18s=; b=Foc7dKiKq0pS9eOW40ho/yQRRK//jiZs/Zh6NRRVj1pvIYOj8bmLL2yFr9XRD11k/w ynM76PCezUSFZcZRyygKqLDO48Jbf9wzyXXAx4jUt1KRtrGS576qa2yqHmPgaoqVkI3+ ca+u8Qd44VnDsUfuvi4b/gwHM8gwUqvfoHOc5uaQ5wk0zTNyCP805Dd+jY7DkdwmBIWl s0R3vuvkmrThI7iamIMiyS36grnNkE3RGzyE+qQTvJZjI04Kq/RWFZz6t6zq4qPTNtAR CoSFwVNAyshx/kNHhgbyLRvmX51I0a5ZGHYlmm8w1tiOBjZazpoW1fKftzw1bVc3uNoG TcRw== 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:in-reply-to; bh=9aJvPPQuZOpMY5U+SSFHkmCbcWziEboEri+b50pt18s=; b=gxoMH/rNFnjT8raqIkwkr4sz5foCgPq5FJK5cbOCtTxp0qyc/ivWG+kuZ+vR4k6Fpx 9d+Pl1mUUe+tpzAvo/Fe5LLi7MmsTzn/rG57npfPVxHxABCrTR15GaXZlPUp3TclDWNL N/ymLg1MLzu5JF3P6KtLbpT6szOmsdp1P46yivJlURk0Boo2E2pZhp/SpWsVrV0b09q8 RM4acHec1pyKFZdQIsDRHKB95yRtaGPUtfA1uC6Ya2sxTYA8e2jJhg7IwTrLbBSqNl5G 5MVN6W9pBDxCFTuhPuRzkiJSvPUopmxsFZct/f04diMyjny3QMQ2fUunVMAz7WKW36Fn q6AQ== X-Gm-Message-State: AOAM532keWUE6hQNuhJOBC1nSM9CyfSCSGFi/q+WvTebAeYe5Hp9LDxE hH3pCD92/jox/rmE84jHFCc= X-Received: by 2002:a17:90a:d48b:: with SMTP id s11mr696019pju.67.1614631195101; Mon, 01 Mar 2021 12:39:55 -0800 (PST) Received: from nuc10 (104.36.148.139.aurocloud.com. [104.36.148.139]) by smtp.gmail.com with ESMTPSA id v123sm18661794pfc.63.2021.03.01.12.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Mar 2021 12:39:54 -0800 (PST) Date: Mon, 1 Mar 2021 12:39:47 -0800 From: Rustam Kovhaev To: Dmitry Vyukov Cc: syzbot , andrii@kernel.org, Alexei Starovoitov , bpf , Daniel Borkmann , John Fastabend , Martin KaFai Lau , KP Singh , LKML , netdev , Song Liu , syzkaller-bugs , Yonghong Song , Greg Kroah-Hartman Subject: Re: memory leak in bpf Message-ID: References: <000000000000911d3905b459824c@google.com> <000000000000e56a2605b616b2d9@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 01, 2021 at 08:05:42PM +0100, Dmitry Vyukov wrote: > On Mon, Mar 1, 2021 at 5:21 PM Rustam Kovhaev wrote: > > > > On Wed, Dec 09, 2020 at 10:58:10PM -0800, syzbot wrote: > > > syzbot has found a reproducer for the following issue on: > > > > > > HEAD commit: a68a0262 mm/madvise: remove racy mm ownership check > > > git tree: upstream > > > console output: https://syzkaller.appspot.com/x/log.txt?x=11facf17500000 > > > kernel config: https://syzkaller.appspot.com/x/.config?x=4305fa9ea70c7a9f > > > dashboard link: https://syzkaller.appspot.com/bug?extid=f3694595248708227d35 > > > compiler: gcc (GCC) 10.1.0-syz 20200507 > > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=159a9613500000 > > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11bf7123500000 > > > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > > Reported-by: syzbot+f3694595248708227d35@syzkaller.appspotmail.com > > > > > > Debian GNU/Linux 9 syzkaller ttyS0 > > > Warning: Permanently added '10.128.0.9' (ECDSA) to the list of known hosts. > > > executing program > > > executing program > > > executing program > > > BUG: memory leak > > > unreferenced object 0xffff88810efccc80 (size 64): > > > comm "syz-executor334", pid 8460, jiffies 4294945724 (age 13.850s) > > > hex dump (first 32 bytes): > > > c0 cb 14 04 00 ea ff ff c0 c2 11 04 00 ea ff ff ................ > > > c0 56 3f 04 00 ea ff ff 40 18 38 04 00 ea ff ff .V?.....@.8..... > > > backtrace: > > > [<0000000036ae98a7>] kmalloc_node include/linux/slab.h:575 [inline] > > > [<0000000036ae98a7>] bpf_ringbuf_area_alloc kernel/bpf/ringbuf.c:94 [inline] > > > [<0000000036ae98a7>] bpf_ringbuf_alloc kernel/bpf/ringbuf.c:135 [inline] > > > [<0000000036ae98a7>] ringbuf_map_alloc kernel/bpf/ringbuf.c:183 [inline] > > > [<0000000036ae98a7>] ringbuf_map_alloc+0x1be/0x410 kernel/bpf/ringbuf.c:150 > > > [<00000000d2cb93ae>] find_and_alloc_map kernel/bpf/syscall.c:122 [inline] > > > [<00000000d2cb93ae>] map_create kernel/bpf/syscall.c:825 [inline] > > > [<00000000d2cb93ae>] __do_sys_bpf+0x7d0/0x30a0 kernel/bpf/syscall.c:4381 > > > [<000000008feaf393>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 > > > [<00000000e1f53cfd>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > > > > > > > > > i am pretty sure that this one is a false positive > > the problem with reproducer is that it does not terminate all of the > > child processes that it spawns > > > > i confirmed that it is a false positive by tracing __fput() and > > bpf_map_release(), i ran reproducer, got kmemleak report, then i > > manually killed those running leftover processes from reproducer and > > then both functions were executed and memory was freed > > > > i am marking this one as: > > #syz invalid > > Hi Rustam, > > Thanks for looking into this. > > I wonder how/where are these objects referenced? If they are not > leaked and referenced somewhere, KMEMLEAK should not report them as > leaks. > So even if this is a false positive for BPF, this is a true positive > bug and something to fix for KMEMLEAK ;) > And syzbot will probably re-create this bug report soon as this still > happens and is not a one-off thing. hi Dmitry, i haven't thought of it this way, but i guess you are right, it is a kmemleak bug, ideally kmemleak should be aware that there are still running processes holding references to bpf fd/anonymous inodes which in their turn hold references to allocated bpf maps