From patchwork Fri Apr 5 08:31:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18639 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id A736081D4E for ; Fri, 5 Apr 2024 10:32:21 +0200 (CEST) ARC-Seal: i=2; cv=pass; a=rsa-sha256; d=open-mesh.org; s=20121; t=1712305941; b=IlE78FmNEO9d6+tHZXTR43nC6VxeXsnyolLjje/4tshL6y0yKb0FGp09NH+hePLiR4eTT UJYIRMq5XrEZVA8zGcBqssK0vrpu7V/96gtp4TaKN7pWMVP+BX7neIncTGpGhlZuT3m2003 SR1RUUrcsSeLq1gT/EtW7i7lfxo4Hd8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1712305941; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=Ch9MwilHZDXX7umbsUSN5w07BMCWYQUWBXlxFjnVbV8=; b=NhDKvkVOjgSJV162b/w4NPOf3ZdvT/h8b0A18xFFvbHwa1iTxHzWYhKqFqMIbIwZOvfy3 nLNQyjc+obcRVE8l4+i0BcsYobZUe0phiz5i/F6vVV+C3bMmhjXkNm2kdA7+NkQIEqdEzDp AREGdCtzfy1dSjniL7GB5Mip6vzPvKw= ARC-Authentication-Results: i=2; open-mesh.org; dkim=fail; arc=pass; dmarc=fail (Used From Domain Record) header.from=simonwunderlich.de policy.dmarc=none Authentication-Results: open-mesh.org; dkim=fail; arc=pass; dmarc=fail (Used From Domain Record) header.from=simonwunderlich.de policy.dmarc=none Received: from mail.simonwunderlich.de (mail.simonwunderlich.de [IPv6:2a01:4f8:c17:e8c0::1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 0D2E381700 for ; Fri, 5 Apr 2024 10:31:31 +0200 (CEST) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1712305891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ch9MwilHZDXX7umbsUSN5w07BMCWYQUWBXlxFjnVbV8=; b=Q3F8CeYCxQE3Dxhg89dJKyRrFBlHY6njqQJNH/op4V1fkUZcQWlu55SrO6YXfu7Ru/kwvQ 4G1CLLkeoCZ/R1r6raXIU4DgSsnMfO+Ar8ZTSnvAAIoyCsQiwfTsHw59er9X041aYLR2QJ jVvjkfOkaOGj0KIMuXFIvwniWu0lTUc= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 2a01:4f8:c17:e8c0::1 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de; dmarc=pass (policy=none) header.from=simonwunderlich.de ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1712305891; a=rsa-sha256; cv=none; b=nMQU96Q1HSuoEqOPfXthUSM7ik8v2/UVnfy3PQJ06cvhvrh/bnruh1tD6IL9A+J9htJvmx npaHiXoufC4nuDkHq6CtOHewz1doWS52USsTWkEcxhPH93ma2SoRAUoQr/Q0CV47nh4IkD 8Hhqa8mMzB1XauI90ZOqomSUDNatgCs= Received: from kero.packetmixer.de (p5de1fdf8.dip0.t-ipconnect.de [93.225.253.248]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.simonwunderlich.de (Postfix) with ESMTPSA id 7DD38FA101; Fri, 5 Apr 2024 10:31:30 +0200 (CEST) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann , stable@vger.kernel.org, syzbot+a6a4b5bb3da165594cff@syzkaller.appspotmail.com, Simon Wunderlich Subject: [PATCH 1/1] batman-adv: Avoid infinite loop trying to resize local TT Date: Fri, 5 Apr 2024 10:31:25 +0200 Message-Id: <20240405083125.18528-2-sw@simonwunderlich.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240405083125.18528-1-sw@simonwunderlich.de> References: <20240405083125.18528-1-sw@simonwunderlich.de> MIME-Version: 1.0 Message-ID-Hash: N2VORJQSJ27YEY5ASSBR4X2XITYSCVZZ X-Message-ID-Hash: N2VORJQSJ27YEY5ASSBR4X2XITYSCVZZ X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; header-match-b.a.t.m.a.n.lists.open-mesh.org-2; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann 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 --- 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;