Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3559408pxv; Mon, 28 Jun 2021 07:23:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyozHSE9lV0Z8ilUNX87mcOOXPBVLIzc+U1PzEExLmczgZjkYDg0Ay49JpPy1rlSyby4Oc8 X-Received: by 2002:a05:6e02:bed:: with SMTP id d13mr17441619ilu.259.1624890224909; Mon, 28 Jun 2021 07:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624890224; cv=none; d=google.com; s=arc-20160816; b=AMXI3snM/+NZiyHQPMGHxeRFKg0U4PBNq5VNsariYXJ4l5Ze6E3trEGICdXjUMUXDH q9CiuRIxQdE6Yz2iar025y8o7VYZeBbeK+36H+xkWN/OluNbIeC7EAY6Hm04JOZ+gg1N KqjgGcoaZKVEz/roM8psixkXjbYXvREJO/WStAR9zBUhl/ryyMOk52wOwnzNPni6lbBy 9YE89/LaUgtdNHopE3N5OgeB6N5o5QEFV1eZL0d2c59sfCcshgNERHR8y+KACrH6y5+o KYyaNYjriUzAbYOq020f7Xgv5mLPr7F1QyIv6drgq6hsURnSKpQ7f0W7wpaAFOk+Inb8 9oMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ODtN9oFvCGAFCjdkJdm8Z8QJR549ywLvJos57z3uYZk=; b=DtBe+V0BgW8qtIf6ZFBVfT5KuILF8pV2IzF3VqSQ+rJKXYWlYftKRiIfJqZrm9StsH XU45QKidtXyhVsKuGUiq9K/XUKVY9nYvkIOYTQP6p6oHfc/vC1hbrV3MxsfYeEh3UgBJ 9BEqyRgwQYQxBkbZpA9patzwo2XouWVLF0c4UQ2u/nV+x9dwWKzFGGyPis3Mgh+YRRjS VlGOWv/07WeeQO1ucbIKn+OdDt2SPEXdcRoMwSNWC6oFmDTrS4vLnL9oF6fALYm/T0/L QgdoyCTb5y8tjRtnYMd4r0NHRTptr0GzdQs/Fn7sLB9F2GcLcadNjLFpsmoIm1RTGFc8 anhg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p3si1089112ils.25.2021.06.28.07.23.32; Mon, 28 Jun 2021 07:23:44 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233589AbhF1OZA (ORCPT + 99 others); Mon, 28 Jun 2021 10:25:00 -0400 Received: from www62.your-server.de ([213.133.104.62]:52636 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232530AbhF1OVg (ORCPT ); Mon, 28 Jun 2021 10:21:36 -0400 Received: from sslproxy03.your-server.de ([88.198.220.132]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lxs6M-0001mq-1O; Mon, 28 Jun 2021 16:19:06 +0200 Received: from [85.7.101.30] (helo=linux.home) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxs6L-000VbA-PF; Mon, 28 Jun 2021 16:19:05 +0200 Subject: Re: [PATCH] bpf: fix false positive kmemleak report in bpf_ringbuf_area_alloc() To: Rustam Kovhaev , ast@kernel.org, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, dvyukov@google.com, andrii@kernel.org References: <20210626181156.1873604-1-rkovhaev@gmail.com> From: Daniel Borkmann Message-ID: <254ef541-6fd6-9ddf-3491-97b854a09554@iogearbox.net> Date: Mon, 28 Jun 2021 16:19:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20210626181156.1873604-1-rkovhaev@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.2/26215/Mon Jun 28 13:09:26 2021) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/26/21 8:11 PM, Rustam Kovhaev wrote: > kmemleak scans struct page, but it does not scan the page content. > if we allocate some memory with kmalloc(), then allocate page with > alloc_page(), and if we put kmalloc pointer somewhere inside that page, > kmemleak will report kmalloc pointer as a false positive. > > we can instruct kmemleak to scan the memory area by calling > kmemleak_alloc()/kmemleak_free(), but part of struct bpf_ringbuf is > mmaped to user space, and if struct bpf_ringbuf changes we would have to > revisit and review size argument in kmemleak_alloc(), because we do not > want kmemleak to scan the user space memory. > let's simplify things and use kmemleak_not_leak() here. > > Link: https://lore.kernel.org/lkml/YNTAqiE7CWJhOK2M@nuc10/ > Link: https://lore.kernel.org/lkml/20210615101515.GC26027@arm.com/ > Link: https://syzkaller.appspot.com/bug?extid=5d895828587f49e7fe9b > Reported-and-tested-by: syzbot+5d895828587f49e7fe9b@syzkaller.appspotmail.com > Signed-off-by: Rustam Kovhaev Applied, thanks! (Also included Andrii's prior analysis as well to the commit log so there's a bit more context if we need to revisit in future [0].) [0] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=ccff81e1d028bbbf8573d3364a87542386c707bf