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 779B53E6DEC for ; Thu, 28 May 2026 11:58:23 +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=1779969504; cv=none; b=UzXHelt+wUBM4Yqs/z7HrlLkNBAKywo+xlAmHnVSz2ScSWZv2AujkRu6Q6A2dypEncOn987nrsVlvx3s7kC6GMXI2WiRnv68S33hxngJgKnXAeTE/wb7zyX/zY1I0OeZLTzBzPwgjYCp6Kefa39SBOXvhfvYFJ2RhHHw05iLaAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779969504; c=relaxed/simple; bh=zISaXYphXFr9OnW3sA3wAtHl4Jwjp0XflN6IWyaKXkQ=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=aoHeUdmIXcJ7eXLwn7idoGTKDb5+IsrkuKle8+ETWf7DePCO+m9hL8E1P7LfDGrG5tSwb515a/ntVxSlj3CZ+M2zgD8sEdRmWQC5GaiqQCKdUmj+17K04EaHKkxEaR5aH32Woo11xml49J5QgA/MyL7D9QIbAai0N8VZh6wvR+M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YABT17GF; 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="YABT17GF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 740791F000E9; Thu, 28 May 2026 11:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779969503; bh=Uf9uT0Xy7V0tuY1qP0J54tInQU4CddylE6tkX5BLOo8=; h=Subject:To:Cc:From:Date; b=YABT17GFKBXsRJoqNU8N1bysAwfH+eEEeRWUMRCNl/NOWEjiVYtXA70ptqHzZCgBk TLq0j+0NcxLPbgcU4RJydhO6+vx0ugwwoeecA2Mg1HRmdYn9M8Srl0PUONEtBNRJmg L4lDeVFFa/BEx7qwVjPAnm5tzlxNfIMcvUnDLa1c= Subject: FAILED: patch "[PATCH] batman-adv: tt: prevent TVLV entry number overflow" failed to apply to 6.1-stable tree To: sven@narfation.org Cc: From: Date: Thu, 28 May 2026 13:57:19 +0200 Message-ID: <2026052819-replace-figure-0a43@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 99d9958fa10fb684b2a8e2c48a8d704122721420 # git commit -s git send-email --to '' --in-reply-to '2026052819-replace-figure-0a43@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 99d9958fa10fb684b2a8e2c48a8d704122721420 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sat, 2 May 2026 21:25:19 +0200 Subject: [PATCH] batman-adv: tt: prevent TVLV entry number overflow The helpers to prepare the buffers for the local and global TT based replies are trying to sum up all TT entries which can be found for each VLAN. In theory, this sum can be too big for an u16 and therefore overflow. A too small buffer would then be allocated for the TVLV. The too small buffer will be handled gracefully by batadv_tt_tvlv_generate() and is not causing a buffer overflow - just a truncated reply. But this overflow shouldn't have happened in the first and the too small buffer should never have been allocated when an overflow was detected. Cc: stable@kernel.org Fixes: 7ea7b4a14275 ("batman-adv: make the TT CRC logic VLAN specific") Signed-off-by: Sven Eckelmann diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 2259b241e0b5..9f6e67771ffa 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -804,11 +804,18 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, u16 total_entries = 0; u8 *tt_change_ptr; int vlan_entries; + u16 sum_entries; spin_lock_bh(&orig_node->vlan_list_lock); hlist_for_each_entry(vlan, &orig_node->vlan_list, list) { vlan_entries = atomic_read(&vlan->tt.num_entries); - total_entries += vlan_entries; + + if (check_add_overflow(vlan_entries, total_entries, &sum_entries)) { + *tt_len = 0; + goto out; + } + + total_entries = sum_entries; num_vlan++; } @@ -893,15 +900,22 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, struct batadv_meshif_vlan *vlan; size_t change_offset; u16 num_vlan = 0; - u16 vlan_entries = 0; u16 total_entries = 0; u16 tvlv_len; u8 *tt_change_ptr; + int vlan_entries; + u16 sum_entries; spin_lock_bh(&bat_priv->meshif_vlan_list_lock); hlist_for_each_entry(vlan, &bat_priv->meshif_vlan_list, list) { vlan_entries = atomic_read(&vlan->tt.num_entries); - total_entries += vlan_entries; + + if (check_add_overflow(vlan_entries, total_entries, &sum_entries)) { + tvlv_len = 0; + goto out; + } + + total_entries = sum_entries; num_vlan++; }