From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78F09129E81; Tue, 30 Apr 2024 10:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714473698; cv=none; b=eQoGol2LuKXInVjWBdLZAY1givhdZtpMzdNw3wfrQcuqLIKxJJ7NOwDhDicmiLfyqw7+jnKjWalHHiipzwRc4JTjS2Cw04SMmK8hzkmnWD/EdBHu8LKOvjGq3zP+Dvi0KsCIeGMDNyu25q4vJ0shNscuHgKPLCYzbJVsJjp+h/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714473698; c=relaxed/simple; bh=/LPXnlxZFU0amWXGRxS8nbV9PmToDNJsIr4V4eJ5hnM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=orTbWCXScnecVxZIFQIyMr2MUTaAwWO2xjB+7gOxB7HIIyYwPpdEE0uYSFPDsPcPS/sP0gEmyhqkR44i6CaNHv8cKOvEca1B6lr8wKSrYwwpBSYf4S4SNNxRwvglaAaAnnOfIvwC9humPA4EyfJvJgranKVN43kKa54xo4suJJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vcV9MUzB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vcV9MUzB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 868CEC2BBFC; Tue, 30 Apr 2024 10:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714473697; bh=/LPXnlxZFU0amWXGRxS8nbV9PmToDNJsIr4V4eJ5hnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vcV9MUzB9oMUtu99hkNGlx3AQaDdNOkP3eUuwBMUcyULWiWinO4glruXct41MEgb6 5/iKJpp85uQWfPilcqp09aydsKdYEwKMiPwv3F7RKXRJ8D1lidO+YRVie4N8HBv3Zg JxzZkHP0wqSn5bYKrI1ZJPE5kN2P3hO6NIz5bU2c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+a6a4b5bb3da165594cff@syzkaller.appspotmail.com, Sven Eckelmann , Simon Wunderlich Subject: [PATCH 4.19 01/77] batman-adv: Avoid infinite loop trying to resize local TT Date: Tue, 30 Apr 2024 12:38:40 +0200 Message-ID: <20240430103041.158350927@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430103041.111219002@linuxfoundation.org> References: <20240430103041.111219002@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sven Eckelmann commit b1f532a3b1e6d2e5559c7ace49322922637a28aa 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: a19d3d85e1b8 ("batman-adv: limit local translation table max size") Reported-by: syzbot+a6a4b5bb3da165594cff@syzkaller.appspotmail.com Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -4198,7 +4198,7 @@ void batadv_tt_local_resize_to_mtu(struc 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;