Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp56823pxj; Wed, 16 Jun 2021 20:11:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL/DA93TcV5/jomC4vvBBS/31vc0MBJlmjuCHwZmt3uLFwiqXGBZvDrrBBtcBTwZjIcsmh X-Received: by 2002:a05:6e02:cc5:: with SMTP id c5mr1928099ilj.152.1623899494855; Wed, 16 Jun 2021 20:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623899494; cv=none; d=google.com; s=arc-20160816; b=zGyxhdApXy9MchzMRjtV4EYPJG+INHXghHDLiv7baYfQP+6vDrTOdYJHx8nww7GC3p beFwqm6e2CVgTnJmEsk9c1qvUUe/cZTga2hFUGnj9dJknh+ptV7q7Kzw/DeRzhZlDdij Z2OdhUsBPd2F4hk77Psb/+2lr102sqOzdM19KPq/56JyRTERq6u4RfdblFD7l6k3NprQ 4HhRgZxYzKoi6SXtaaXlCHPRpy//DTVtucC1RE563eDQa38+f1PnZmqz9UvXpkHkRLJF YlYV2E9+PkKGFDVt+hxzcFzM3hvuqZgfBQGO4SvC9LQrt/4URot9aoC/+1D003xyrTT2 vadw== 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=bRtaAEoX3Wl0MO3YfnMNq5KlU2cGESsyfs3QuKUrWMQ=; b=LidnBbWyCzDnNAyXPdIqIsArW28jlymsSanbugXFojgXtzfpP4igF36CIP3SXc+eC6 Vch8gvvqbTtf+53u1oIDzw3reQowYRnsNQYfHSVemqax4T2w4X+0Upv7dsiBoyw9sNiA n/MtkWkIVIVDeXvNylIlMWyLcH/5hyzMV2qcQQyJx/8PztiNZ4Vj2wFzgd3yyIxgQeIL qRZd5TIfHqrab5S83ja22yv72d2ofxUinR722p46aeqVt9TM7mgFwYGOb9g+bfFwf/y+ GbNyVWkTTVvqZ5HfsTPs7VAmTZJnUF0rfXL2pICTpqL2t7Asmob1cNktsoTP7r0ql8MH GBGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CAoFIeiN; 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 f11si4970643jaj.69.2021.06.16.20.11.23; Wed, 16 Jun 2021 20:11:34 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CAoFIeiN; 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 S231757AbhFPS3k (ORCPT + 99 others); Wed, 16 Jun 2021 14:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbhFPS3j (ORCPT ); Wed, 16 Jun 2021 14:29:39 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C620DC061574 for ; Wed, 16 Jun 2021 11:27:31 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id x16so2857963pfa.13 for ; Wed, 16 Jun 2021 11:27:31 -0700 (PDT) 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=bRtaAEoX3Wl0MO3YfnMNq5KlU2cGESsyfs3QuKUrWMQ=; b=CAoFIeiN+kNL5A5BZHLElpwpf4fB4PXibrFkfkDg8jZjg15B195hYji4FYq8ABOz5h fhMq9LN8zMSFD0XsprRhS/FWD2vwOdmBVW9O2ZCM68g+Ry9OJBV3CkZ2kgolm0Cm37Kb vhSXd75tmELfkUSVvZoVFuDtYjaakHpmlrvaWQlQVeCEs8zURtwXiGWnX2M4qtVP0C1M +MhVTCxOIMV1MQC5MrO/dzWR3ZnmYQOWxig2p+zr01yYHgMSRsFljmm9x82tqhk67qGo Cnw8Y43FPg7HAUqhj5U1e+EaMFF81qaouNrfEi3sw1LBeTwn4BTHyxOitSwcdRcsQ6hz 2mrg== 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=bRtaAEoX3Wl0MO3YfnMNq5KlU2cGESsyfs3QuKUrWMQ=; b=QcL5uGLhC+VztUDc1rfRzmBwalzcIfFtwhtJM0GlwH9y9ehSX+T7yNoGAGH3lkNogg MErW7mjTq9ICcscCMia87x1OHN3GPRZY0VHvofDTrvoFfj5+4oAoeusI0PWdi1qgypFm nXlQXhRZs74xCWh57XP9IADg8zbMOFvXGA2EkbihVFdZeSRDTlOhQ8eVGs79zitIDQgH /7xuygA577Lbs+4QWJPiHjEFp9aG4qsGfgmeLv9/sPpPDxlk/8Amodgh1Apa9sglFVKb OxTUJch0He6iUTfxCV7bzzyjNtLfRH5vFD22nXYdEAxZzckQwdlSLcPQujs+4t6LV37w x1dA== X-Gm-Message-State: AOAM533qvvtCMBuWYLusWGk28og8SWqM1APC9oVqHLLeRHPM01SEMCXz nqQjyR0Zf1b+60nlffFNUBQ= X-Received: by 2002:a63:4e4d:: with SMTP id o13mr892766pgl.361.1623868051314; Wed, 16 Jun 2021 11:27:31 -0700 (PDT) Received: from nuc10 (104.36.148.139.aurocloud.com. [104.36.148.139]) by smtp.gmail.com with ESMTPSA id g8sm3145642pja.14.2021.06.16.11.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 11:27:31 -0700 (PDT) Date: Wed, 16 Jun 2021 11:27:26 -0700 From: Rustam Kovhaev To: David Hildenbrand Cc: Catalin Marinas , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, dvyukov@google.com, gregkh@linuxfoundation.org Subject: Re: kmemleak memory scanning Message-ID: References: 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 Tue, Jun 15, 2021 at 10:12:06AM +0200, David Hildenbrand wrote: > On 14.06.21 22:31, Rustam Kovhaev wrote: > > hello Catalin, Andrew! > > > > while troubleshooting a false positive syzbot kmemleak report i have > > noticed an interesting behavior in kmemleak and i wonder whether it is > > behavior by design and should be documented, or maybe something to > > improve. > > Hi, > > See below regarding documentation. > > > apologies if some of the questions do not make sense, i am still going > > through kmemleak code.. > > > > a) kmemleak scans struct page (kmemleak.c:1462), but it does not scan > > the actual contents (page_address(page)) of the page. > > if we allocate an object 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. > > should we improve kmemleak and make it scan page contents? > > or will this bring too many false negatives? > > I looked into this a while ago to see which parts of the kernel end up > reading random physical page content and was happy to see that kmemleak does > *not* scan random physical memory :) > > We have to be very careful when reading random physical page content, > especially in virt environments this is really undesired, or when dealing > with memory holes, memory with problematic semantics like gart memory ... i see, makes sense, thank you for the info! > > The doc (Documentation/dev-tools/kmemleak.rst) states "Page allocations and > ioremap are not tracked.", which includes the alloc_page() example you gave > I think. i see it now, ty!