[PATCH] batman-adv: Avoid infinite loop trying to resize local TT
From: Sven Eckelmann
Date: Mon Feb 12 2024 - 07:10:33 EST
If the MTU of one of an attached interface becomes too small to transmit
the local translation table then it must be resized to fit inside all
fragments (when enabled) or a single packet.
But if the MTU becomes too low to transmit even the header + the VLAN
specific part then the resizing of the local TT will never succeed. This
can for example happen when the usable space is 110 bytes and 11 VLANs are
on top of batman-adv. In this case, at least 116 byte would be needed.
There will just be an endless spam of
batman_adv: batadv0: Forced to purge local tt entries to fit new maximum fragment MTU (110)
in the log but the function will never finish. Problem here is that the
timeout will be halved in each step and will then stagnate at 0 and
therefore never be able to reduce the table even more.
There are other scenarios possible with a similar result. The number of
BATADV_TT_CLIENT_NOPURGE entries in the local TT can for example be too
high to fit inside a packet. Such a scenario can therefore happen also with
only a single VLAN + 7 non-purgable addresses - requiring at least 120
bytes.
While this should be handled proactively when:
* interface with too low MTU is added
* VLAN is added
* non-purgeable local mac is added
* MTU of an attached interface is reduced
* fragmentation setting gets disabled (which most likely requires dropping
attached interfaces)
not all of these scenarios can be prevented because batman-adv is only
consuming events without the the possibility to prevent these actions
(non-purgable MAC address added, MTU of an attached interface is reduced).
It is therefore necessary to also make sure that the code is able to handle
also the situations when there were already incompatible system
configurations present.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: a19d3d85e1b8 ("batman-adv: limit local translation table max size")
Reported-by: syzbot+a6a4b5bb3da165594cff@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Sven Eckelmann <sven@xxxxxxxxxxxxx>
---
net/batman-adv/translation-table.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index b95c36765d04..2243cec18ecc 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3948,7 +3948,7 @@ void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface)
spin_lock_bh(&bat_priv->tt.commit_lock);
- while (true) {
+ while (timeout) {
table_size = batadv_tt_local_table_transmit_size(bat_priv);
if (packet_size_max >= table_size)
break;
--
2.39.2
--nextPart8334104.T7Z3S40VBb
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEF10rh2Elc9zjMuACXYcKB8Eme0YFAmXKHQAACgkQXYcKB8Em
e0ZN1hAAm4AZPTLa+Uy9iVugO8Yew0bm/73u6VXYtlop/Cj88PdsTAvJtgTO1lXw
Cc23VMSQmgXGVn0kRolo8QnDRDtc4w+icm6LVMJmqHn9YKXiUutDrVjytMUhOglu
X1iR7iRB4deA36lvm2hS4EQEzJQO+u4qwa1BQnUEg/G2X+p5dgYJKwejoLVrklw+
ydyxP31lGadzr7FbqZXMRPxcMcMDmAbp4FkhHBfmb9F1UYXJMWpK8efzJlGlyaCb
kf9Mv7LLUVhXfQmJR9Co27CouKQtI5lMBKBcJglvnFAQ0KqTf0CPn7C0D17V0slN
6kCwS4+oPqcK/PoTyA6DrszeSpbkmiRel+vtxsQItI90t4D8BIlCPVpA/F3WZIT0
kERxR0byXoWHLQhkVQr/vs2rBxbCZU6v7PZOrEbTg1W7cfEslXrv9jSyFD51tFNi
FpH8h5gQJ7Qujcl63MprFvfreKH8JxXHe42yaAxV9h2AmDDzdaPzu3W2uyHDPU2L
K2VksYSFkoE8H/KHW3UAk2H6eZ30fEBQInYxaE/X/cpZ4ecA7VRXD5cEUlbtMRA8
fgwPbhebbj2av7TnLrOHf64sngV1sSd7FMfcAIuMeWu29ALH8z0GpIODrseUIRZF
j3dNrQgQ1viz370WF2AftqaEBEp2+cEpzVoG1MRXbHx+ag2NjaU=
=1+AJ
-----END PGP SIGNATURE-----
--nextPart8334104.T7Z3S40VBb--