Article View: linux.kernel.netdev
Article #9274Re: [PATCH net v2 14/14] batman-adv: tt: limit local table to single TVLV response size
From: netdev-bot+sashiko
Date: Sun, 01 Nov 2026 13:52
Date: Sun, 01 Nov 2026 13:52
217 lines
16527 bytes
16527 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message describes the pre-patch behaviour wrongly.
- [Low] Two kernel-doc comments no longer match the code after this
patch.
Pre-existing issues:
- [Low] This problem wasn't introduced by this patch, but the same 16-bit
tvlv_len limit is still not enforced when a node answers a TT_REQUEST…
- [Low] This problem wasn't introduced by this patch, but the size limit
is read before the lock is taken.
--
batman-adv: tt: limit local table to single TVLV response size
This patch adds batadv_tt_local_transmit_size_max(). It caps the local TT
reservation and the resize-to-MTU limit at the smaller of packet_size_max
and the largest full table response that fits in a single unicast TVLV
packet with a 16 bit tvlv_len. The reservation logic now computes the new
totals in locals and writes the counters only when the reservation
succeeds.
> The size limit was already missing the 16 bit tvlv_len cap since the
> original packet_size_max check was introduced. But this check was only
> reachable with fragmentation disabled and a hard interface MTU larger than
> the maximum unicast TVLV packet. In this case,
> batadv_tt_prepare_tvlv_local_data() refuses to build the full table
> response and no oversized packet is created.
[Severity: Low]
Does this describe the old behaviour accurately?
batadv_tt_prepare_tvlv_local_data() only bounds the TT value with a u16,
and does not count the 4 byte struct batadv_tvlv_hdr:
if (check_add_overflow(*tt_len, change_offset, &tvlv_len)) {
batadv_tvlv_unicast_send() then adds the header and stores the result
without a range check:
tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len;
...
unicast_tvlv_packet->tvlv_len = htons(tvlv_len);
All TT components are multiples of 4, so a 65532 byte TT value is
reachable. For example, 1 VLAN and 5460 entries gives 4 + 8 + 65520.
Before this patch, the reservation allowed that table whenever
packet_size_max >= 65556. The full table response would then be built and
sent with tvlv_len = 65536, which htons() truncates to 0. So an oversized,
malformed packet does seem to have been created. The receiver in
batadv_recv_unicast_tvlv() then just processes no TVLVs.
The code change handles this for the local table: table_size includes the
TVLV header and is capped at sizeof(struct batadv_unicast_tvlv_packet) +
U16_MAX.
The stable+noautosel reasoning depends on how the old behaviour is
described. Could the commit message be made more precise here?
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index f0100ccf93deb..46304069b3b75 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
[ ... ]
> @@ -266,6 +269,25 @@ static int batadv_tt_local_transmit_size(u16 num_vlan, u16 num_entries)
> return hdr_size + batadv_tt_len(num_entries);
> }
>
> +/**
> + * batadv_tt_local_transmit_size_max() - get the maximum size of a full local table
> + * response
> + * @bat_priv: the bat priv with all the mesh interface information
> + *
> + * The full table response is sent as a single unicast TVLV packet. Its
> + * tvlv_len, which covers the TVLV header and the TT TVLV, is only 16 bit wide.
> + * This limits the response size even when packet_size_max is larger.
> + *
> + * Return: maximum size of a full local table response in bytes
> + */
> +static int batadv_tt_local_transmit_size_max(struct batadv_priv *bat_priv)
> +{
> + int tvlv_size_max = sizeof(struct batadv_unicast_tvlv_packet) + U16_MAX;
> + int packet_size_max = READ_ONCE(bat_priv->packet_size_max);
> +
> + return min(packet_size_max, tvlv_size_max);
> +}
[Severity: Low]
This is a pre-existing issue and was not introduced by this patch. The
same 16 bit tvlv_len limit does not seem to be enforced when a node
answers a TT_REQUEST on behalf of another originator.
batadv_send_other_tt_response() only checks this:
/* Don't send the response, if larger than fragmented packet. */
tt_len = sizeof(struct batadv_unicast_tvlv_packet) + tvlv_len;
if (tt_len > READ_ONCE(bat_priv->packet_size_max)) {
That check leaves out the 4 byte batadv_tvlv_hdr. It also has no cap at
sizeof(struct batadv_unicast_tvlv_packet) + U16_MAX.
batadv_tt_prepare_tvlv_global_data() has the same u16-only
check_add_overflow() as the local variant.
A remote originator's global entries come from OGM TT diffs. The local
reserve_lock accounting does not limit them.
Take fragmentation disabled and a hard interface MTU >= 65552. A relayed
table with a 65532 byte TT value (1 VLAN and 5460 entries) passes both
checks. batadv_tvlv_unicast_send() then sends it with tvlv_len truncated
from 65536 to 0.
Only the local reservation and resize paths use the new
batadv_tt_local_transmit_size_max(). Would a check in
batadv_tvlv_unicast_send() that rejects tvlv_value_len >
U16_MAX - sizeof(struct batadv_tvlv_hdr) cover every caller?
> @@ -290,22 +312,23 @@ static int batadv_tt_local_transmit_size(u16 num_vlan, u16 num_entries)
> static bool batadv_tt_local_reserve(struct batadv_priv *bat_priv, u16 num_vlan,
> u16 num_entries, int *table_size)
> {
> - int packet_size_max = READ_ONCE(bat_priv->packet_size_max);
> + int size_max = batadv_tt_local_transmit_size_max(bat_priv);
> + unsigned int entries;
> + unsigned int vlans;
>
> scoped_guard(spinlock_bh, &bat_priv->tt.reserve_lock) {
[Severity: Low]
This isn't a bug introduced by this patch, but the limit is still read
before reserve_lock is taken. The old code had the same READ_ONCE() before
the guard. batadv_tt_local_resize_to_mtu() also reads the limit before
taking commit_lock.
Can a concurrent MTU decrease leave the local table larger than the new
packet_size_max?
CPU0 CPU1
batadv_tt_local_add()
batadv_tt_local_reserve_entry()
batadv_tt_local_reserve()
size_max = <old, larger limit>
batadv_update_min_mtu()
batadv_hardif_min_mtu()
WRITE_ONCE(packet_size_max, ...)
batadv_tt_local_resize_to_mtu()
/* table fits, nothing purged */
scoped_guard(reserve_lock)
reservation committed against
the stale size_max
entry inserted
The purge decision uses batadv_tt_local_table_transmit_size(), which only
counts vlan->tt.num_entries. It does not see in-flight reservations
(tt.reserved_entries and tt.reserved_vlans) or entries that still carry
BATADV_TT_CLIENT_NEW.
Nothing checks the table again until entries age out, so full table
responses may be dropped until then.
[ ... ]
> @@ -4727,16 +4752,16 @@ void batadv_tt_local_resize_to_mtu(struct net_device *mesh_iface)
> struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
> int timeout = BATADV_TT_LOCAL_TIMEOUT / 2;
> bool reduced = false;
> - int packet_size_max;
> int table_size;
> + int size_max;
>
> - packet_size_max = READ_ONCE(bat_priv->packet_size_max);
> + size_max = batadv_tt_local_transmit_size_max(bat_priv);
>
> spin_lock_bh(&bat_priv->tt.commit_lock);
>
> while (timeout) {
> table_size = batadv_tt_local_table_transmit_size(bat_priv);
> - if (packet_size_max >= table_size)
> + if (size_max >= table_size)
> break;
[Severity: Low]
Should the kernel-doc be updated to match? The kernel-doc for
batadv_tt_local_resize_to_mtu() still says:
* batadv_tt_local_resize_to_mtu() - resize the local translation table fit the
* maximum packet size that can be transported through the mesh
The loop now compares against batadv_tt_local_transmit_size_max(), and the
log message below already says "maximum table response size".
The kernel-doc for batadv_tt_local_reserve() also still describes the old
add-then-drop handling:
* Add the requested number of VLANs and local TT entries to the reservation
* counters and check whether the local translation table would then still fit
* in a single full table response. The reservation is dropped again when it
* would not.
The new body computes the totals in vlans and entries and writes the
counters only on success. Nothing is dropped any more.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261030135105.2555887-2-sw%40simonwunderlich.de
Technical Details
Message-ID:
<179354114897.3131.2074837253295301799@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354233-linux-kernel-netdev=dewy.ruReferences:
<20261030135105.2555887-15-sw@simonwunderlich.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354233-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 14/14] batman-adv: tt: limit local table to single TVLV response size Date: Sun, 01 Nov 2026 13:52:28 +0000 Organization: Usenet Network Message-ID: <179354114897.3131.2074837253295301799@kernel.org> References: <20261030135105.2555887-15-sw@simonwunderlich.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2696616"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:JnjEgaFheUgzufFS4zeWFzKFurM= sha256:vsUaBFFozgOHL99fSaG+nobtdFWIdPkVENMtZcUnWzs= sha1:eaCfn31nI0eH7NBKkmee//rmzRo= sha256:HZnJL/gA7Cds+CAaBNnF4ZlUZtJsRm7Gr3GSV0Tn/d4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 674E0114003; Sun, 1 Nov 2026 16:52:58 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ekskGxfZAoGk; Sun, 1 Nov 2026 16:52:49 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354233-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 64D3F11232B; Sun, 1 Nov 2026 16:52:40 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id BEAD8261C7; Sun, 1 Nov 2026 13:52:31 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793541151; b=1x/frx/LKBdiC0m1lKDesv+4LxBEwTGmXW1Rnia013tDC8Y/RQL6vZmRDc1H4UBcE3NJ hdGyw/QqL5ejnlHtO5LVgOQIKVhIsocbsLDmsWcIJpm3WdIoCE1LTgLfijwFdyaBH/5xk KfEyjTKoh7R3tHMFDHoPNOrPaZDtpekcNp2NutLFM/REsc3A9iQ/TdlNufs9Xethl1IxQ zeMPef3RpzpcSrsnrOgy/HdF9Lzhgw0OFOmqAKj1ceHMenXhtbDdEokLFeqyeNIL6OgCa oxKU37kF2Pno6Bv7thuIXWMaWU4MV8kfXqsyjZ6osxIT3LxybQP5AK53oSPlAUKcQ7w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793541151; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=deb38tc0CgShiFlGF5y7hmWXUTuA2F88Y7i/kEhYh3M=; b=WjRRfDDq8zXz+6fZLoRRkIutBomq5iut7D+XWaYBXB36B3OGcltlqBoSCMKCr0Ttf5nc 43t6LQlQnhmLdWp5faiHuIC5txsMplgzo+Dkd1rcJOac0jaMtZIVGnQMnjW10YSnyqwwa W+PsTRl1tRvtzhHMXdRTP4J/Z9H6QmqQ3lCZ3TdCjxKaxoe6X9N/q5ovLQc/IScrBHD9g UQKvWzIoLF/ifMwCKqHiQDx1K2mhdkqYlwK4gkWN1CujcpAbTwHKFoZlnkpCiVqWwkv+Q 3e7yLGp27/x6Eja051ENvMFzQiVtIB7hXvvy1w3HRivC048nrewisJM6i8qoTMzZuRQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UlZV96RB; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F885606A332; Sun, 1 Nov 2026 13:52:31 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UlZV96RB X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793541150; b=rtBQA69BCY+dOBfcsAF8Wq20wOUFCDu+VJZG6J3cJkbvXHd5Ly5EAROc9ZxT7tLmeQhC FqwS7H34KrKczlkBD5v2UNmpBe11djlcFlqDvI6Qh7zQ7UVyaAUpP/iFXTNG2ktsiCCvG Frpr5JLgEQqxkxSGDJL3JfPOlx7/A2doCx0FCbZkBTXFeOFcAgTe9bJ0lgLjbNriBnRGV Jh+BJxTpBthYlBIKmYVfkkSsVV1payJ0KXP4ntklHLhMEL2C8EjdKpIuJ0dU4v27wZBk8 8gWTt4FL5Xb/LdqMmKO69fWsr5maMio7QICGDKywsIUNvIawH7xeLMgdpcKRAVHukyA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793541150; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=deb38tc0CgShiFlGF5y7hmWXUTuA2F88Y7i/kEhYh3M=; b=dPA74r0RgNahsRBrVgKQHbtS+O2YQLHfxzQVBfxMcIdrF/815bG/HpZ55JrGzpA2oJoK O+klHRj79igrie0f0bF5bBRlr76Fg+sva2O812WaOchw5s6AzjJIqfkqsCd+bMHqowxaR tT8UplhdJgp7sg2Dyd8MgSeYhLhNukzzzSPbwzNm2fx9/vgoE1LaAtdiplFt2KS/zG5an oo4OaxfTc3xW/I8jGemBLbU1cEvedaB51cS20KrVEWBMO+kP4urQZws511pjTEvAUv5Vw S2ibwVHZUQ+SxYzxRcASPQasb+W0PfsHmHPJEOYMEgKeQTKYu77l6XLmMxag9fMxEuQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UlZV96RB; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B77D606A329; Sun, 1 Nov 2026 13:52:30 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F8781F00919; Sun, 1 Nov 2026 13:52:29 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793541149; bh=deb38tc0CgShiFlGF5y7hmWXUTuA2F88Y7i/kEhYh3M=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=UlZV96RBa96zsrI7RFMGrUd8i1Ob8IZtOTlfGFPhJxCZEtVQthfeXaWyJM8HxDmQz kPXnoGJmPFdKFtMuiGMtqrkHiMp2i/3gc3WIAnLbM+P1iP4nPBwPSHQO0/I6MKNn6H lkqHcRwhMfJhGOY+gIYrroKl0hl7OvcvEF4BCZrTApsd0n4Cn/RF7PWkBd9zJn9GYc r/CNYGxOXBzkkxD+GslCJJPPfWWcAXpS+23ohDQjsrFsLYeChqEMeEueMJ9RBLtsBl kSNxSluRAACSHvTZ9zgFnVautGO20+Q6EPqgaYa4CXS2/buLNWff8e8SdUN53rxMer O4pB1AWLu6tIA== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, b.a.t.m.a.n@lists.open-mesh.org, sven@narfation.org, stable@vger.kernel.org, sashiko-bot@kernel.org X-In-Reply-To: <20261030135105.2555887-15-sw@simonwunderlich.de> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list