From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 7B01A241C8C; Sat, 30 May 2026 18:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164951; cv=none; b=N5ta2UMVXHsNslzOdt0VmmIW4zC1DdNUoMWDJoMaiQ6V4VWqIAFgy+HctscyyAM8IbNtV/8XzeyNSjFS8J/9TkBRE6dGQZgmd4mkFVLCPgFPWKEMQKNA4mMBWZyvlHgomesGqV8dbnEzsUqpF6AXJxcS1Afw/1oFYlTUMEJENUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164951; c=relaxed/simple; bh=ysKx1o+2m/u8QvtaPiZZLyzk5osjEyw02VT4XXhgyqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oZEIttrIK8VtII7lJOfW0eJ312K5RXk+3fDJ+RkENk/jrVD924koCAe41WNBOsjv0pmwU4TkXFvOy6NX64uXPuHtUUrZb+p964goo5a3ot9rRlQLc1RmFFmFoppEjf3wkMWGo+/1OU+k6e/l3JJcHncyUUHxZBn+PC2UCcHn53A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QIeLwFzl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QIeLwFzl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CC0E1F00893; Sat, 30 May 2026 18:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780164950; bh=bcv4wWOzuCr4qoBVfvJEgNQKzJ/gPbpQgRMIWQ4HXuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QIeLwFzldIhHLptxEPQkEyY8g3cuyZHRr3ywA5f1jaCRWF+Gh8P3OAecX+MoEFd4V pQEKUNuYl/xCpg7L9uFEaEe+sAxI8y1v/I0HK+CaoGEUY0xfNlLyYHobyWxNstad/Q PWfQ+wwvQ0zJl/jMItxFts/fUVT5NFUcIJ8iqBbs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, =?UTF-8?q?Linus=20L=C3=BCssing?= , Sven Eckelmann Subject: [PATCH 5.15 706/776] batman-adv: mcast: fix use-after-free in orig_node RCU release Date: Sat, 30 May 2026 18:07:00 +0200 Message-ID: <20260530160258.091073736@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sven Eckelmann commit 20c2d6a20ca936f5aaa6dd40f73f262ac45c87cc upstream. batadv_mcast_purge_orig() removes entries from RCU-protected hlists but does not wait for an RCU grace period before returning. Concurrent RCU readers may still accesses references to those entries at the point of removal. RCU-protected readers trying to operate on entries like orig->mcast_want_all_ipv6_node will then access already freed memory. Fix this by moving batadv_mcast_purge_orig() to batadv_orig_node_release(), just before the call_rcu() invocation. This ensures RCU readers that were active at purge time have drained before the orig_node memory is reclaimed. Cc: stable@kernel.org Fixes: ab49886e3da7 ("batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support") Acked-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/originator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -823,8 +823,6 @@ static void batadv_orig_node_free_rcu(st orig_node = container_of(rcu, struct batadv_orig_node, rcu); - batadv_mcast_purge_orig(orig_node); - batadv_frag_purge_orig(orig_node, NULL); kfree(orig_node->tt_buff); @@ -878,6 +876,8 @@ void batadv_orig_node_release(struct kre /* Free nc_nodes */ batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL); + batadv_mcast_purge_orig(orig_node); + call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); }