From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 950CF303CB0; Fri, 15 May 2026 16:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778861519; cv=none; b=mtPz8w9HVJoYN1YGzdMdAVMLb/OVHL3FqQhDFkkUCxF0zCdNFiG2WiZrNQ+RB+HnfKj3iSmWGtGwIGoNAOycoj6jurk0XB9jliRUnIGNQVR/SgKHkfyhUcEV9WXfCThYsFh35ejxfL+2z1PKk/HsLnlotK86OqBH87luT6I+wgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778861519; c=relaxed/simple; bh=ottGAUj9sviCgB5/h9DVDJZ1VSpBj5qrANpH/0Aj+XQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a6fdOkIOqgMKOx5ucJ3u7+ouYwi/1wdBt1wnZIony9RAVroPdKDT0GZhsI1VEx8RT4mpF2U5YcLyP4mpaI1GjtZMlbV6U5lw6EPMSSmjM0c6lV/maw19qMnc+tWi8cdR2ycwKpR/X7yRFdrBkprX91HDUWBSmzPfbqnSw/VwU7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X4qI9P4v; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="X4qI9P4v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A8F4C2BCB0; Fri, 15 May 2026 16:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778861519; bh=ottGAUj9sviCgB5/h9DVDJZ1VSpBj5qrANpH/0Aj+XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4qI9P4v2Y0lWAUDJ2QOeY5rbR8gpPSp5ossCBkrJA87rypRpOQpZc8xtRDQ72LS4 434YuLNvN2NpXDrMEQXw0YBVUBSZimPtgKYiGMEGusI4jPrg7I7dmdHFWf/UxcXPh8 37KUTa0EGQiVFf1Fwn5rq8S1a1slGavrI5Ksz19I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Sven Eckelmann Subject: [PATCH 6.6 360/474] batman-adv: bla: only purge non-released claims Date: Fri, 15 May 2026 17:47:49 +0200 Message-ID: <20260515154722.807863336@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sven Eckelmann commit cf6b604011591865ae39ac82de8978c1120d17af upstream. When batadv_bla_purge_claims() goes through the list of claims, it is only traversing the hash list with an rcu_read_lock(). Due to a potential parallel batadv_claim_put(), it can happen that it encounters a claim which was actually in the process of being released+freed by batadv_claim_release(). In this case, backbone_gw is set to NULL before the delayed RCU kfree is started. Calling batadv_bla_claim_get_backbone_gw() is then no longer allowed because it would cause a NULL-ptr derefence. To avoid this, only claims with a valid reference counter must be purged. All others are already taken care of. Cc: stable@kernel.org Fixes: 23721387c409 ("batman-adv: add basic bridge loop avoidance code") Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/bridge_loop_avoidance.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -1288,6 +1288,13 @@ static void batadv_bla_purge_claims(stru rcu_read_lock(); hlist_for_each_entry_rcu(claim, head, hash_entry) { + /* only purge claims not currently in the process of being released. + * Such claims could otherwise have a NULL-ptr backbone_gw set because + * they already went through batadv_claim_release() + */ + if (!kref_get_unless_zero(&claim->refcount)) + continue; + backbone_gw = batadv_bla_claim_get_backbone_gw(claim); if (now) goto purge_now; @@ -1313,6 +1320,7 @@ purge_now: claim->addr, claim->vid); skip: batadv_backbone_gw_put(backbone_gw); + batadv_claim_put(claim); } rcu_read_unlock(); }