]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.19/batman-adv-avoid-infinite-loop-trying-to-resize-local-tt.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.19 / batman-adv-avoid-infinite-loop-trying-to-resize-local-tt.patch
CommitLineData
88153929
GKH
1From b1f532a3b1e6d2e5559c7ace49322922637a28aa Mon Sep 17 00:00:00 2001
2From: Sven Eckelmann <sven@narfation.org>
3Date: Mon, 12 Feb 2024 13:58:33 +0100
4Subject: batman-adv: Avoid infinite loop trying to resize local TT
5
6From: Sven Eckelmann <sven@narfation.org>
7
8commit b1f532a3b1e6d2e5559c7ace49322922637a28aa upstream.
9
10If the MTU of one of an attached interface becomes too small to transmit
11the local translation table then it must be resized to fit inside all
12fragments (when enabled) or a single packet.
13
14But if the MTU becomes too low to transmit even the header + the VLAN
15specific part then the resizing of the local TT will never succeed. This
16can for example happen when the usable space is 110 bytes and 11 VLANs are
17on top of batman-adv. In this case, at least 116 byte would be needed.
18There will just be an endless spam of
19
20 batman_adv: batadv0: Forced to purge local tt entries to fit new maximum fragment MTU (110)
21
22in the log but the function will never finish. Problem here is that the
23timeout will be halved all the time and will then stagnate at 0 and
24therefore never be able to reduce the table even more.
25
26There are other scenarios possible with a similar result. The number of
27BATADV_TT_CLIENT_NOPURGE entries in the local TT can for example be too
28high to fit inside a packet. Such a scenario can therefore happen also with
29only a single VLAN + 7 non-purgable addresses - requiring at least 120
30bytes.
31
32While this should be handled proactively when:
33
34* interface with too low MTU is added
35* VLAN is added
36* non-purgeable local mac is added
37* MTU of an attached interface is reduced
38* fragmentation setting gets disabled (which most likely requires dropping
39 attached interfaces)
40
41not all of these scenarios can be prevented because batman-adv is only
42consuming events without the the possibility to prevent these actions
43(non-purgable MAC address added, MTU of an attached interface is reduced).
44It is therefore necessary to also make sure that the code is able to handle
45also the situations when there were already incompatible system
46configuration are present.
47
48Cc: stable@vger.kernel.org
49Fixes: a19d3d85e1b8 ("batman-adv: limit local translation table max size")
50Reported-by: syzbot+a6a4b5bb3da165594cff@syzkaller.appspotmail.com
51Signed-off-by: Sven Eckelmann <sven@narfation.org>
52Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
53Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
54---
55 net/batman-adv/translation-table.c | 2 +-
56 1 file changed, 1 insertion(+), 1 deletion(-)
57
58--- a/net/batman-adv/translation-table.c
59+++ b/net/batman-adv/translation-table.c
60@@ -4198,7 +4198,7 @@ void batadv_tt_local_resize_to_mtu(struc
61
62 spin_lock_bh(&bat_priv->tt.commit_lock);
63
64- while (true) {
65+ while (timeout) {
66 table_size = batadv_tt_local_table_transmit_size(bat_priv);
67 if (packet_size_max >= table_size)
68 break;