Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1555397rdb; Mon, 2 Oct 2023 13:21:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwRRu7FqB2EjZYvCNKzJQHOpdJ+/8LTK4Rpx0hmVya95sZsXc6qvZKN4QikKd1ok7KmctQ X-Received: by 2002:a05:6808:10c8:b0:3a4:633:44d2 with SMTP id s8-20020a05680810c800b003a4063344d2mr16772065ois.18.1696278106562; Mon, 02 Oct 2023 13:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696278106; cv=none; d=google.com; s=arc-20160816; b=vMTbYc5aDMDtcxPw/YN8G3rZD4u6Ze2JO+RNWLjLUpa5nRvdC7KYmW3CWEUq+aR6FE 7MEWRg8hy9Wl+dXQytJ4GRof4HSuU5vlnWeFJHcQU/zbzsidYZDEF1m7cmeBSMkGwgTH DePdvE1Y0TTjpT7NHh7aKIjVmFZ6Jl8zhVVY5UOJHYi7o0bKUy5v1TctlUPS5iMtbNnO VUBZ5onafKcYDT3mxA0/hj1PnwwrdByYBph9JR3fMIud7qPn9/nCiKjaaqbsI9t/n/fZ 7RTKhdPd7zwspMWmQuR42hEhNT0ptj9D92cviJoSEOzZ8m8L/FrpleFMQTpMgy51Hxsd jnzA== 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:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=f1V2zIuTahPpDbSJumzi7NpzoIi0H96vdVLjA3zZQYg=; fh=8uLLEVDkcPObswqstBATqX+l+NyJF04d8cutDiK1tXk=; b=0to6UkQpcULxt0An1entxUV3G/ajNbSEmkUReKszOgOh++m/iZ6UMNzPBFtwXwrApZ CIkGKEoDIdPNkZUTMR0ETte7ImBHDhg87qA8mgEv9ZRg8z+RxKXgy2VV2hD2mmX8jVYv /Vb/FW9PHrCl+QKAIYHbbAwSy0nRwIqVjRaJJLxDBZP4fISlL5lPkzeORRNWZKKBpQJD qGUm4VYixrErAkDZuZ2Wiq+rROkuRNvkcwbU7rTrcwpDbTkLKBc86+EWZH2ZOHBXRJYx ivdkG05O+Pkgm0wO3/YHhfTRJ++o7h9fqHSnc9bUJXmghPMeQvapeogw7Trs6S5e1x6S Ltzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tv8Bnt3S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x21-20020a17090aca1500b00274afd5346esi8256886pjt.151.2023.10.02.13.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 13:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tv8Bnt3S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0C8F7809D449; Mon, 2 Oct 2023 13:11:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234669AbjJBULf (ORCPT + 99 others); Mon, 2 Oct 2023 16:11:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjJBULf (ORCPT ); Mon, 2 Oct 2023 16:11:35 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B1B3AC; Mon, 2 Oct 2023 13:11:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2590C433C8; Mon, 2 Oct 2023 20:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696277491; bh=ncy0wGCJ2hjg3VoApdm7ly5waa7mSKZO5dkfG6H7ffI=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=tv8Bnt3SwTOSbyTlHiMANimfqbRCq6Iq097sOUqA/sdsvl/arSp0xe0lJJTMwtmbd 4aMIzPWq8A48XMFBGBlfmjB6sfxVB0Bh4vpgi4sEiMvdVyHhBn44XYAXgbUGnHVqP2 rDgAsPXhfES5zGuSjE9b3Xf5ppqYRBDPixp8BToTXmOKaF9YM8jpCGWqxe8iBts4jH 0km++HpV8WqwlwmsDG0Z34Uv8Sgae6KRMpAIYVV0XNApAJCoY/U0YvN5+5SHccZGs5 sVPTpW7bljjoJJyxpwpsngRfwCkJdVunVJKL9jNXoO8wPyNgPdNwYcwxYiASnpEacy DQUALCusRN7sg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 4417ECE0591; Mon, 2 Oct 2023 13:11:31 -0700 (PDT) Date: Mon, 2 Oct 2023 13:11:31 -0700 From: "Paul E. McKenney" To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Catalin Marinas , Christoph Paasch , stable@vger.kernel.org, rcu@vger.kernel.org Subject: Re: [PATCH] rcu: kmemleak: Ignore kmemleak false positives when RCU-freeing objects Message-ID: Reply-To: paulmck@kernel.org References: <20230930174657.800551-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230930174657.800551-1-joel@joelfernandes.org> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 02 Oct 2023 13:11:50 -0700 (PDT) On Sat, Sep 30, 2023 at 05:46:56PM +0000, Joel Fernandes (Google) wrote: > From: Catalin Marinas > > Since the actual slab freeing is deferred when calling kvfree_rcu(), so > is the kmemleak_free() callback informing kmemleak of the object > deletion. From the perspective of the kvfree_rcu() caller, the object is > freed and it may remove any references to it. Since kmemleak does not > scan RCU internal data storing the pointer, it will report such objects > as leaks during the grace period. > > Tell kmemleak to ignore such objects on the kvfree_call_rcu() path. Note > that the tiny RCU implementation does not have such issue since the > objects can be tracked from the rcu_ctrlblk structure. > > Signed-off-by: Catalin Marinas > Reported-by: Christoph Paasch > Closes: https://lore.kernel.org/all/F903A825-F05F-4B77-A2B5-7356282FBA2C@apple.com/ > Cc: > Tested-by: Christoph Paasch > Signed-off-by: Joel Fernandes (Google) Reviewed-by: Paul E. McKenney > --- > kernel/rcu/tree.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index cb1caefa8bd0..24423877962c 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -31,6 +31,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -3388,6 +3389,14 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr) > success = true; > } > > + /* > + * The kvfree_rcu() caller considers the pointer freed at this point > + * and likely removes any references to it. Since the actual slab > + * freeing (and kmemleak_free()) is deferred, tell kmemleak to ignore > + * this object (no scanning or false positives reporting). > + */ > + kmemleak_ignore(ptr); > + > // Set timer to drain after KFREE_DRAIN_JIFFIES. > if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING) > schedule_delayed_monitor_work(krcp); > -- > 2.42.0.582.g8ccd20d70d-goog >