Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7608206rwr; Wed, 10 May 2023 10:10:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4eIBRRWJZ0lEkB84E5tpEoqglisVLIihCSYpAt0rGgwEYHpedOs7aVPvQKJeZlufa1mBlR X-Received: by 2002:a17:902:c949:b0:1ab:8f4:af21 with SMTP id i9-20020a170902c94900b001ab08f4af21mr24254769pla.42.1683738657431; Wed, 10 May 2023 10:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683738657; cv=none; d=google.com; s=arc-20160816; b=AaNRsYmLWlbY5SfXdt199Tn3pUgZTIp2tUwQsME9mmoRSAriVFuMGL8gEgt12ZAbLZ PErHHrGrW9i3GrK7x3shPqFM4K2Z8fELRFuT4dlqyXSMxDUqGKV11vpbieeE8woSVMrB dY2pS9sW4XXBl3QfbB8RgYqr3xnYIQyMgVPbhiA1LGZQ69+Iy000iSZyBJubotGxSTy/ jIy8dbvBuAKdDBP463jkI5tKRd81Tl7QtsdONhLI64DweQ7maIR4GfHSyTtEcHXfSx2M WeqBedyYmwQxcaNpQVqeBECjoPdEXHtCw3B70/YTcu4vt4Dr/FuFvZEjyhMPyOua5j6n rsQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w2nx73+BpseFUA7Z1D1vP9+UD7W2SSJLf4X9jnv7h5U=; b=AlZhnLjeiAaFywiNGUAKSRTN9DS23LWf0AIyD/McWlaLgqRAjBEK92YrelJEncQ3D/ oJ2pCXwupe+YbLiM+sXAOexu1qgFOGrteJ7StZapClgPfnvyhx1xJPikpMgHJQpPUnQZ 8k4EGMTwsI+YiJ+kxloITQUHDNw16GbrOOXKbTrf/qhSgw8UHk+/x8yYhPb9Ps7L1Ylk KDZvvQXjfQujhu04hLTdwk3HL0+2tugEVM1w+uWUaFwlknnVpGge8RcESGdf87lJJKIb sebP1lA4d+FFwLpZ/5hOhq/CNFP7idZe14NTWoKaudn71EXw2ifT6sRVkRGDKVcMkC8I eFCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gEGNa6dS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a17090270c200b001ab1d1a6803si4098539plt.420.2023.05.10.10.10.36; Wed, 10 May 2023 10:10:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gEGNa6dS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236290AbjEJRDV (ORCPT + 99 others); Wed, 10 May 2023 13:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236215AbjEJRDL (ORCPT ); Wed, 10 May 2023 13:03:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE38C4ED7; Wed, 10 May 2023 10:02:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 59C2564A1E; Wed, 10 May 2023 17:02:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6226C4339C; Wed, 10 May 2023 17:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683738163; bh=877l4CUT4YO2vkuyC7nkck2lZ0w74fb2w1R/1pwbZ18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gEGNa6dSoOgt9+0HxMDmt57xJjCygj0zhXTETavEwjfa3Hl7hfzFrojx5XUZ56JWy BUmtu6X6B45ftCN2ByBaeiYFZixPdbX4DS2ZufelFxsC04PPONnHizxSyN6TkLmQg4 14lxT/WV7S3CxzZPcTXBz6p8mUkOxNab1JjF+0lSk4Rf6L78CxTAormgPG/TwggwV6 WMw9BmtpOklml6aKvMh3Y3UK6aSsqBVj+IJCRL6trJclf77OeTSHKyHU1VdRBbaPpP G2voZG2/d28ay4Wl+zgQT9j1dECnn9SRxQkbIrw9+3+lmhz46KIqv8o8Z1oRZkTm75 a70W2YoEFHPjw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 53BD2CE127D; Wed, 10 May 2023 10:02:43 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Zqiang , "Paul E . McKenney" Subject: [PATCH rcu 4/8] rcu/kvfree: Invoke debug_rcu_bhead_unqueue() after checking bnode->gp_snap Date: Wed, 10 May 2023 10:02:38 -0700 Message-Id: <20230510170242.2187714-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <1c01c38f-3783-44d7-8c11-7416cd5b849c@paulmck-laptop> References: <1c01c38f-3783-44d7-8c11-7416cd5b849c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zqiang If kvfree_rcu_bulk() sees that the required grace period has failed to elapse, it leaks the memory because readers might still be using it. But in that case, the debug-objects subsystem still marks the relevant structures as having been freed, even though they are instead being leaked. This commit fixes this mismatch by invoking debug_rcu_bhead_unqueue() only when we are actually going to free the objects. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 7452ba97ba34..426f1f3bb5f2 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2922,8 +2922,8 @@ kvfree_rcu_bulk(struct kfree_rcu_cpu *krcp, unsigned long flags; int i; - debug_rcu_bhead_unqueue(bnode); if (!WARN_ON_ONCE(!poll_state_synchronize_rcu_full(&bnode->gp_snap))) { + debug_rcu_bhead_unqueue(bnode); rcu_lock_acquire(&rcu_callback_map); if (idx == 0) { // kmalloc() / kfree(). trace_rcu_invoke_kfree_bulk_callback( -- 2.40.1