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 8E7FA26B973; Thu, 28 May 2026 20:01:55 +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=1779998516; cv=none; b=InoFjmx1NVeaQI6EA8Xixo2Gwnt4FX49Dx8RjfS8/Qw4bYFAxSKWwwLA4NQ2APsTKBdEr9rtY1SO8IobrSTlNbutwCtxCjYS7RLGi/j7bFNS2aYZbY8fDf8WMoAjBbNSW/FjJz+yvG6tHuzTdHFWuPHCELiHxzt4fxG/zJ0mzNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779998516; c=relaxed/simple; bh=TkC3ZH8ctwInf+XAqVCvJddP9AAzv6CeOMAPZdzgOmU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EsshyAYrCJLJo9QSiZdQ+LFq9Yyzn+SrFWfKkYAKvjgQ/3rVCGqSO9uQP425DX5GxSVbLi/S8froTO3TAg/CzUsP/dV6DyiVIW7VZiXmHJ+ztKT8uO0Qm95wE1KJsiDX//XiLOs+TKlmMBkuWBorkRwIpnf4vrg3u0gHP61EGsc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DhQLWP0V; 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="DhQLWP0V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0056F1F000E9; Thu, 28 May 2026 20:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779998515; bh=jCKvEzOEIPx87jhgk30U+t8RkwRaaf0ixToUQhVuXk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DhQLWP0VL7Q20zn28/FWIr7d0dE2+AuqNZRUwYZVQokUyErvlClI3TtdYAt3JW9iL WVLgIgXiZ1MR+7rLOudd2TqkA89xpEYQqaDXH/veLkb4Z0RyGT5lP1wrpQSYWAHz0y LVRG8F+OFVp5gZCOoMOkOKbBLruuDbrGo4m758oI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Yuan Tan , Yifan Wu , Juefei Pu , Xin Liu , Sven Eckelmann Subject: [PATCH 7.0 154/461] batman-adv: tp_meter: avoid use of uninit sender vars Date: Thu, 28 May 2026 21:44:43 +0200 Message-ID: <20260528194651.500583540@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194646.819809818@linuxfoundation.org> References: <20260528194646.819809818@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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sven Eckelmann commit 6c65cf23d4c6170fcf5714c32aa64689718cb142 upstream. batadv_tp_recv_ack() and batadv_tp_stop() are only valid for tp_vars in the BATADV_TP_SENDER role. When called with a BATADV_TP_RECEIVER role, it proceeds to read sender-only members that were never initialized, leading to undefined behavior. This can be triggered when a node that is currently acting as a receiver in an ongoing tp_meter session receives a malicious ACK packet. Guard against this by checking tp_vars->role immediately after the lookup and bailing out if it is not BATADV_TP_SENDER, before any of those members are accessed. Cc: stable@kernel.org Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation") Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Xin Liu Reviewed-by: Yuan Tan Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/tp_meter.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -663,6 +663,9 @@ static void batadv_tp_recv_ack(struct ba if (unlikely(!tp_vars)) return; + if (unlikely(tp_vars->role != BATADV_TP_SENDER)) + goto out; + if (unlikely(atomic_read(&tp_vars->sending) == 0)) goto out; @@ -1100,12 +1103,16 @@ void batadv_tp_stop(struct batadv_priv * if (!tp_vars) { batadv_dbg(BATADV_DBG_TP_METER, bat_priv, "Meter: trying to interrupt an already over connection\n"); - goto out; + goto out_put_orig_node; } + if (unlikely(tp_vars->role != BATADV_TP_SENDER)) + goto out_put_tp_vars; + batadv_tp_sender_shutdown(tp_vars, return_value); +out_put_tp_vars: batadv_tp_vars_put(tp_vars); -out: +out_put_orig_node: batadv_orig_node_put(orig_node); }