linux-stable/net/batman-adv
Sven Eckelmann 04720ea2e6 batman-adv: Avoid infinite loop trying to resize local TT
commit b1f532a3b1 upstream.

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 all the time 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
configuration are present.

Cc: stable@vger.kernel.org
Fixes: a19d3d85e1 ("batman-adv: limit local translation table max size")
Reported-by: syzbot+a6a4b5bb3da165594cff@syzkaller.appspotmail.com
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-02 16:17:08 +02:00
..
Kconfig
Makefile
bat_algo.c
bat_algo.h
bat_iv_ogm.c batman-adv: Avoid WARN_ON timing related checks 2021-06-30 08:48:15 -04:00
bat_iv_ogm.h
bat_v.c
bat_v.h
bat_v_elp.c batman-adv: Do not get eth header before batadv_check_management_packet 2023-08-30 16:31:55 +02:00
bat_v_elp.h
bat_v_ogm.c batman-adv: Fix batadv_v_ogm_aggr_send memory leak 2023-08-30 16:31:55 +02:00
bat_v_ogm.h
bitarray.c
bitarray.h
bridge_loop_avoidance.c net: batman-adv: fix error handling 2021-11-02 18:26:45 +01:00
bridge_loop_avoidance.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh 2020-10-01 13:14:52 +02:00
debugfs.c
debugfs.h
distributed-arp-table.c batman-adv: Broken sync while rescheduling delayed work 2023-06-14 10:57:13 +02:00
distributed-arp-table.h
fragmentation.c batman-adv: Don't skb_split skbuffs with frag_list 2022-05-18 09:42:47 +02:00
fragmentation.h
gateway_client.c batman-adv: Avoid uninitialized chaddr when handling DHCP 2020-09-09 19:04:24 +02:00
gateway_client.h
gateway_common.c
gateway_common.h
hard-interface.c batman-adv: Don't increase MTU when set by user 2023-08-30 16:31:55 +02:00
hard-interface.h
hash.c
hash.h
icmp_socket.c
icmp_socket.h
log.c batman-adv: set .owner to THIS_MODULE 2020-12-02 08:48:10 +01:00
log.h
main.c net: batman-adv: fix error handling 2021-11-02 18:26:45 +01:00
main.h
multicast.c batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN 2021-11-26 11:36:24 +01:00
multicast.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN 2021-11-26 11:36:24 +01:00
netlink.c batman-adv: fix uninit-value in batadv_netlink_get_ifindex() 2019-09-16 08:21:41 +02:00
netlink.h
network-coding.c net: batman-adv: fix error handling 2021-11-02 18:26:45 +01:00
network-coding.h
originator.c
originator.h
routing.c batman-adv: mcast/TT: fix wrongly dropped or rerouted packets 2020-10-01 13:14:51 +02:00
routing.h
send.c
send.h
soft-interface.c batman-adv: Don't increase MTU when set by user 2023-08-30 16:31:55 +02:00
soft-interface.h
sysfs.c batman-adv: Fix refcnt leak in batadv_store_throughput_override 2020-05-14 07:57:22 +02:00
sysfs.h
tp_meter.c
tp_meter.h
translation-table.c batman-adv: Avoid infinite loop trying to resize local TT 2024-05-02 16:17:08 +02:00
translation-table.h
tvlv.c
tvlv.h
types.h batman-adv: Don't increase MTU when set by user 2023-08-30 16:31:55 +02:00