From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796032263; b=W596DqZt3I1w4Zgv/4xBfCHhQK6q9NP9PqWMz7BUbOQjD2Gz00XjgEfC0oHL1mPmIiQ/ ivuYLWdiQ3f5c4ZjMTmXkWgh8pYoAvfbbiogUvZOynw4wyunWy6gqcyBa0A+lMi4iNxfi I3rIORpYPtkcHOOKrZYsjXecVoGAfQHeYZCld/t0KpIJXwopfGaVpvtpcd0LuI0g+94Bc D//1Wt7dqDhFFvQb0l3WuKL4QQe2fxLbgKwhwkY3ZYIk84cNStHdiWOeQRWvU6nwEzaJq bbzWdaggaQPnbppq9+Hat0Z9jaDbN5vfuPCWepn5rzIqBPZKB3/qFKBmeu+9m7ObBJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796032263; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=kYb/KYV0+yQX9lLPTMiPCz3phqpK7Nx/2B2F+l+a5kk=; b=HETBDBAWIbchQHmfxjCBGObbtxrT2LuNwkZt4sg4NSVeIxTex0I27rdlxW/Lk1Gsz4Sz mpPrEtIlr3jDzCaCn7Rk8scusbXoX26pWfWzjjr3DCnDNR7M/6wXQxvbvBzcIgxtK6ppF HSQlxy419PsYGhlpAjI/AyqWCyybVzpE9IHF8uFtcsqH0Fjm6AKU1DczN3hpjd4fGmpho 2f5/NDeDXP760h1nW/gSG+eicM/pAjriK33bb+ohmHKSH9MYGqoxS6B9yzTgyqPcYPiGa ikPtj2xIl2IcJYIVmeQn7RkhtvsDf/4peIMYfcoH1LdVfIeSg6Jf1MXHuFvRgtWZMdQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=blockcast.net; spf=pass smtp.mailfrom=blockcast.net; dkim=pass header.d=blockcast.net header.i=@blockcast.net header.a=rsa-sha256 header.s=google header.b="EJ0z3Yf/"; arc=none smtp.remote-ip=74.125.82.42 Received: from mail-dl1-f42.google.com (mail-dl1-f42.google.com [74.125.82.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D184A606A32F for ; Mon, 30 Nov 2026 09:51:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D184A606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=blockcast.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=blockcast.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=blockcast.net header.i=@blockcast.net header.a=rsa-sha256 header.s=google header.b=EJ0z3Yf/ Received: by mail-dl1-f42.google.com with SMTP id a92af1059eb24-1b59dfe466bso2827626c88.1 for ; Mon, 30 Nov 2026 01:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockcast.net; s=google; t=1796032262; x=1796637062; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=kYb/KYV0+yQX9lLPTMiPCz3phqpK7Nx/2B2F+l+a5kk=; b=EJ0z3Yf/x1hACTch4tHIXi39vHkS+ePVJrN5NWb+iyw4INk4g5Gc1Mc2zLYjdXGiT1 XsfZw4pF37YgGDtU/DiGZTccv8XNFsY9qN0GuDmexRV6XR3shx6BUJOALr89tr72YG0B HPElJq4ughIF/+f+HIqwIkVX1L+Q4VRqI+IRVhjAw1on3C1NedyOcTRWvKZ5nrUwDZVb 13fsvlJs8YiaOhJap2I/4D9UioCyups8mPMoGID1uYgNx3pNT5GRfgdxz2xgDOEL73hD DpSeUXcBoNAUR+ZaUEikpB0ccs7f7iDhgbnl/Kxr98ViObvhTObixCmh7tz3aUhw+T/A 1V8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796032262; x=1796637062; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kYb/KYV0+yQX9lLPTMiPCz3phqpK7Nx/2B2F+l+a5kk=; b=Qdij0kSygDwyoBKhGTmWfPElLSsJBIvqZsJppR9E5RyV1VdJ83YWQm9BsFUlOGRFnz fj1axwGGfcXJd7Pv7l6+uFfqxWZHlCfbX1ZfKNDler5T0JsCGEOPd7BdEcMoUygu7mcd qigcot1AgfWmrOeOnNSVAoIj7VqiWB4lm920Zy4aVbVZXpnXmYPs/OWlKvSMAE7Iq2u5 vGEpjZqwzmoE8jymWfultyhrAEjxogO/7hcr38xHc+1OJ3BrKF318A8Uq2BQsGWkJGMX esB2GMErLe5XMvO6epbaGmK60b+GKgfD3NvOv11A9EIlGApunXUfqXzIvor1TA3El22J jgWw== X-Forwarded-Encrypted: i=1; AL+hErF/ifZsDmktnkRjMf2eyfCdUF/FZWq2et741+zX1z1bdA5H78spqrHsSMDv4DXI2FEgPuvLGX7TfDcaroU=@vger.kernel.org X-Gm-Message-State: APuU4Z9Po4wOyMaNjjGgXsNB9iv+FkRSsl5mL1X8ieBz6kFEVe44FCGI WmgB7BTMUWgZIVLXjQ4qVosCLvg9q1Z99szXCp6Uply8u8Qj2kkgB9bXDrY7mr5lWMM= X-Gm-Gg: AZFdTZfPg21knctLpppItcmba7AqrgHORJtCHJojOAo/5V9C2DvSlUHyf64KdyeKZ1V Gum9WUDKfNWB+ymd406t+bN5iD5j2TP1CkL30CQh45yAEFc7dPnoyGjxd19citWM5ND1lzg3dR1 5hcPq5sCvtZGDtndnAz0ePA9+BzvA7V0C33bPIqWV1vJEMMzM0AH2/5pRovWmDG9bTW4I7nSFsd YcTnZqQWnEUKO9/WGInOwuL5Fwzhahkxgu6Xz0vd/z3UQ7DHdgHbOA7+JgYtwAF1gXWrgYvczAa uGOkx4Gssf7/pTp6HFnoFo31ZsHN0eFgxJxNHsoKXsjzOT/WrMz/HoUzbH5TuGrlQY3DcK+2D1F F7XEM0jB/ghciZ8VGSBwHNvuu4mRBWdL84eAEXHQlOF4+K4ziI3vqRHFRqKhT1c2KOGZSz9B0/9 O4dC2jXMdHywbgnE5Zln/7ri3VsUFAHRP8CpM/IsDTmSfA7Zss9tWpgevAt9TuA6G1EwBIzRhLZ p63/ym+ywdcxYk+iJUReCwh6sVUx+hKPuWYhFZyTfuEomYgyL9OrUTDpfw4wb34erUSR00UlcVM 5XqLuzJCj0Dhrb2Bt0RJI3CHMQQ1uv4i5a0wwllNwMjfCTvgteliU9WilVYz/sfygukG9dZj4PZ zJ5SwZN7ZApxdwzwK+T/wLE/xKp7N2oc6ee5SMvTufCrI6ojz X-Received: by 2002:a05:7022:299:20b0:1b5:877b:4894 with SMTP id a92af1059eb24-1b5877b4ae8mr17254309c88.14.1796032261761; Mon, 30 Nov 2026 01:51:01 -0800 (PST) Received: from devbox.ts.blockcast.net ([2602:f74d:1::32]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b562a82b3fsm93595422c88.5.2026.11.30.01.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 01:51:01 -0800 (PST) From: Omar Ramadan To: Taehee Yoo , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Willem de Bruijn Subject: [PATCH net-next v5 0/3] amt: configurable per-tunnel limits, with bounded report work Date: Mon, 30 Nov 2026 09:50:56 +0000 Message-ID: <20261130095059.1301582-1-omar@blockcast.net> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A relay caps one gateway tunnel at 32 group and 128 source records, both compile-time constants. v2 made them configurable [1]. Sashiko and Paolo pointed out that at the new ceilings a single Membership Update can livelock the host: records are applied under tunnel->lock in softirq, and only the packet length bounds them [2]. This series keeps the processing in the RX path and bounds it instead: 1/3 makes the A-B case of amt_lookup_act_srcs() linear. It used to compare every source in the group with every source in the record. 2/3 charges every group record for the passes it makes over its group and stops applying records once a report exceeds twice the cost of refreshing the tunnel's whole state. A record for a group the tunnel has no room for does no walk of the group and is charged only for the group lookup, so a host joined to more groups than max_groups keeps its refreshes. 3/3 is v2 with the group ceiling lowered from 1024 to 512. The hashes keep their 256 buckets, so one tunnel at the ceilings holds about 2.75 MiB [estimated, from pahole sizes]. Since twice a full refresh grows with the limits, it also caps the budget of 2/3 at what one report as large as the device's MTU can cost: a host splits its report to the MTU, so a report names at most mtu / 8 groups and mtu / 4 sources. Changes in v5 (netdev's Sashiko review of v4 [4]): - 3/3 (Medium): the MTU bound no longer drops below a legitimate refresh when the relay's own MTU is low. It assumes at least an Ethernet link and covers at least min(max_groups, 187) groups. At the defaults the bound stays 120,320 unless the relay's MTU is below 528, and is then no lower than the 60,160 that refreshing 32 groups costs; v4's message said the defaults always kept it. - 3/3 (Medium): a lookup that misses walks the whole chain of its bucket, which holds max_sources / hash_buckets entries on average, and was charged as one visit. It is now charged for that many, one at the defaults and 16 at 4096 sources, and the lookups the MTU bound may charge are capped at the sources a report of that size can name. The bound at the ceilings on a 1500-byte link is 440,448, up from v4's 416,256, which left the chain length out. - 2/3: a record for a group the tunnel has no room for is charged for its group lookup, at most max_groups chain entries; v4 charged it nothing, so one report of such records naming one group could repeat that lookup thousands of times uncharged. The message says the Update is reachable from the network, and the AMT_REC_LOOKUPS comment lists amt_add_srcs() as the seventh lookup. - The largest legitimate report at the ceilings on that link costs about 357,000, not the 348,000 of v4's cover letter. - I did not add Fixes: tags: 2/3 and 3/3 are net-next material here, and 1/3 only changes the A-B walk's complexity. The work one Membership Update may cause, in bucket, source and chain-entry visits [estimated, from the code], at 32 groups / 128 sources and at the ceilings of 512 groups / 4096 sources: defaults ceilings v3 120,320 3,850,240 v4 120,320 416,256 (1500-byte stream link) this version 120,320 440,448 (1500-byte stream link) Measured cost of one Membership Update under tunnel->lock, in a UML guest (KASAN off, so slower than native; compare the columns only), with the relay at the ceilings. v3 and this version were built from the same base and booted alternately on one machine, five rounds each [measured]. The measurement harness now fills the attack's group the way a host does, in records that each fit the link's MTU; v4's harness sent one 16 KB record at MTU 1500, which this version refuses: one Update, relay at the ceilings v3, ms v5, ms attack, stream MTU 1500 (64 KiB of empty records naming one 4,096-source group) 14.4 - 17.6 2.4 - 3.2 records applied before the budget stops 119 14 the same attack, stream MTU 65535 14.4 - 17.7 15.5 - 18.7 records applied 119 98 refresh of 512 groups x 8 sources in 1,400-byte reports, slowest report 0.19 - 0.28 0.14 - 0.23 the same refresh in one 64 KiB report 1.9 - 3.9 1.4 The runner was slower than the one v4 was measured on, so compare the columns, not v4's figures. At a relay MTU of 65535 this version does not bound the attack below v3's: the first bound, twice a refresh, now counts lookups by chain length, so it is about 1.5 times v4's 2.0 million there. Without 2/3 (v2), the attack report held tunnel->lock for about two seconds (measured for v3's cover letter, on another machine). Deferring report processing to a per-tunnel work item would also take the work out of softirq. I have not done that here: with the work bounded, the deferral would add a queue and its own limits without changing the worst case much. Happy to do it if you prefer. This depends on the net series "amt: relay tunnel lifetime, validation and request-path hardening" [3], which is in net-next; this is based on ccb81d5e317b, which carries it. Testing: tools/testing/selftests/net/amt.sh, unmodified, on net-next 24630ff92eff with this series applied, x86_64 under virtme-ng/KVM (4 vCPUs, 4 GiB) with generic KASAN (inline), PROVE_LOCKING, PROVE_RCU and AMT=y: all six tests pass, amt.sh exits 0, and no KASAN, lockdep or WARNING report appeared during the run. amt.sh does not reach the new limits, so this covers the normal paths only; the budget is covered by the measurements above. Each patch builds with W=1 C=1, with IPv6=y and IPv6=n, with no warnings in amt. The struct layouts are unchanged from v4: pahole gave 200 bytes for amt_group_node and 168 for amt_tunnel_list, so with 256 bucket heads both stay within 4 KiB. [1] https://lore.kernel.org/netdev/20261015231825.2852054-1-omar@blockcast.net/ [2] https://lore.kernel.org/netdev/361bbccf-6ce7-4b1f-bd55-4d8270423320@redhat.com/ [3] https://lore.kernel.org/netdev/20261110210538.217936-1-omar@blockcast.net/ [4] https://lore.kernel.org/netdev/20261124210501.70394-1-omar@blockcast.net/ Omar Ramadan (3): amt: make the A-B source walk linear amt: bound the source-state work of one Membership Update amt: make the per-tunnel group and source limits configurable drivers/net/amt.c | 161 +++++++++++++++++++++++++++++++++------ include/net/amt.h | 21 +++++ include/uapi/linux/amt.h | 8 ++ 3 files changed, 167 insertions(+), 23 deletions(-) base-commit: ccb81d5e317b0ae2cc66ca1c628c0ca907928f94