linux-stable/net/batman-adv
Sven Eckelmann 3fe79b2c83 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-04-17 11:18:22 +02:00
..
Kconfig This feature/cleanup patchset is an updated version of the pull request 2021-02-08 11:32:40 -08:00
Makefile batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bat_algo.c batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bat_algo.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bat_iv_ogm.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
bat_iv_ogm.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bat_v.c batman-adv: Drop NULL check before dropping references 2021-08-08 20:21:40 +02:00
bat_v.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bat_v_elp.c batman-adv: Do not get eth header before batadv_check_management_packet 2023-08-30 16:11:07 +02:00
bat_v_elp.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bat_v_ogm.c batman-adv: Fix batadv_v_ogm_aggr_send memory leak 2023-08-30 16:11:07 +02:00
bat_v_ogm.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bitarray.c batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bitarray.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
bridge_loop_avoidance.c batman-adv: remove unnecessary type castings 2022-04-22 11:23:46 +02:00
bridge_loop_avoidance.h batman-adv: Remove the repeated declaration 2021-05-30 13:38:27 +02:00
distributed-arp-table.c batman-adv: Broken sync while rescheduling delayed work 2023-06-14 11:15:23 +02:00
distributed-arp-table.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
fragmentation.c batman-adv: Don't skb_split skbuffs with frag_list 2022-04-17 23:41:44 +02:00
fragmentation.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
gateway_client.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
gateway_client.h batman-adv: Check ptr for NULL before reducing its refcnt 2021-08-08 20:21:40 +02:00
gateway_common.c batman-adv: Switch to kstrtox.h for kstrtou64 2021-08-08 20:05:46 +02:00
gateway_common.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
hard-interface.c batman-adv: Don't increase MTU when set by user 2023-08-30 16:11:07 +02:00
hard-interface.h batman-adv: Check ptr for NULL before reducing its refcnt 2021-08-08 20:21:40 +02:00
hash.c batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
hash.h batman-adv: Fix spelling mistakes 2021-06-02 08:46:03 +02:00
log.c isystem: ship and use stdarg.h 2021-08-19 09:02:55 +09:00
log.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
main.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
main.h batman-adv: Start new development cycle 2022-08-17 12:09:21 +02:00
multicast.c This cleanup patchset includes the following patches: 2022-03-02 21:58:03 -08:00
multicast.h batman-adv: mcast: don't send link-local multicast to mcast routers 2022-01-02 09:31:17 +01:00
netlink.c batman-adv: Hold rtnl lock during MTU update via netlink 2023-08-30 16:11:08 +02:00
netlink.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
network-coding.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
network-coding.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
originator.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
originator.h batman-adv: Check ptr for NULL before reducing its refcnt 2021-08-08 20:21:40 +02:00
routing.c batman-adv: prepare for const netdev->dev_addr 2021-10-20 14:22:25 +01:00
routing.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
send.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
send.h batman-adv: bcast: queue per interface, if needed 2021-05-17 12:00:44 +02:00
soft-interface.c net: vlan: introduce skb_vlan_eth_hdr() 2023-12-20 17:00:16 +01:00
soft-interface.h batman-adv: Check ptr for NULL before reducing its refcnt 2021-08-08 20:21:40 +02:00
tp_meter.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
tp_meter.h batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
trace.c batman-adv: Drop publication years from copyright info 2021-02-06 09:22:10 +01:00
trace.h batman-adv: Drop unused headers in trace.h 2022-08-17 12:10:43 +02:00
translation-table.c batman-adv: Avoid infinite loop trying to resize local TT 2024-04-17 11:18:22 +02:00
translation-table.h batman-adv: Check ptr for NULL before reducing its refcnt 2021-08-08 20:21:40 +02:00
tvlv.c batman-adv: Migrate to linux/container_of.h 2022-03-02 09:00:13 +01:00
tvlv.h batman-adv: prepare for const netdev->dev_addr 2021-10-20 14:22:25 +01:00
types.h batman-adv: Don't increase MTU when set by user 2023-08-30 16:11:07 +02:00