From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.226 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795917654; b=nRufEqKOfUB5vrHsRAuxITqZS80Un0DGFDd3hsRHkCFJsK3ZurF17l5iwp++db/N4hLc 45aKT6Hrb1bN4omDWCa+PRcqbWT7Ymg8B7+O6MuEke8qOtMqVfyx22e5Bx2mf5mZL2K0f tD1EyPKOYP91de8sP8omod1bITEuvITVktghvCUAMmEpUoVwE7dX7xjWu6Hz5TDPy+wLC EYVZ9wr9di3+2eo1W03ktjaRdapa1vlXJWjMpjUTlmBm2DgqYPyxEbS3Oul6/8Om3Xwj8 vMT7f2Zkq7igSmPYl3M38sQm+vX94ty9bj9/CLm2pvPjQEDGjtgcOapbyr1RIvql9Kw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795917654; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: X-Relaying-Domain:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Kr4+CIp0OyMS3P43z0dXIPJU2QAiHr5wTzugTPF8gCI=; b=fec3LAhXzXGYjckJX9I8Ih6qmUh3J6eYC29vS1I0YXXbSDLdqZjWYgT2b9Wl4wFqSXc/ o69VixzLB/KSzN3Xx8WLFZ/fhU65tffh6EHRWXng2X+NYGRe5JzzOEf0mmsySQehPg58c mA+aTjKW6kcmHHLGEeiOzNQqd2qDUBVZMpDpW6Es9cGztuaqshSpwV0t/ZuU2dA+4p9uZ 53wUQaGrpZEVPViwbJeMMYdJrbE1piOaN0ibtCb0acytwJYsjVXZmZGd7aNRCrecE+Ilf h6JDfsUF6q4ruxUHp/cHX8S14LiXPQ/9XqD8+wFCPs8aSNpsMljxf0q8D4qPC0CcBzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=andrii.net; spf=pass smtp.mailfrom=andrii.net; dkim=pass header.d=andrii.net header.i=@andrii.net header.a=rsa-sha256 header.s=gmail-2025 header.b=GXoqln+N; arc=none smtp.remote-ip=209.85.222.226 Received: from mail-qk1-f226.google.com (mail-qk1-f226.google.com [209.85.222.226]) (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 A1E1B606A33A for ; Sun, 29 Nov 2026 02:00:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A1E1B606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=andrii.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=andrii.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=andrii.net header.i=@andrii.net header.a=rsa-sha256 header.s=gmail-2025 header.b=GXoqln+N Received: by mail-qk1-f226.google.com with SMTP id af79cd13be357-9495e8ae23aso760872485a.2 for ; Sat, 28 Nov 2026 18:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrii.net; s=gmail-2025; t=1795917653; x=1796522453; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Kr4+CIp0OyMS3P43z0dXIPJU2QAiHr5wTzugTPF8gCI=; b=GXoqln+NmGvnoMiJbSTZ4bK8VeLYfIuZTcFPeIpb27FWRclLb4Q9v/mQ8iyhilmpo9 Y4nuTiHbULAQp5HQGZ2pU51OCHRTkB8MIMMQm9RgEPy/YAXqihLtnMocRKoDjABDp2gP 1JsHagsywpLkUYB1Q0RyeLo2+kZJbs043YRLD8+Olh11mP1c5bxSAmvq0OaRJEReVHfj xQg5CV7K6uRgqDW1SRbNbaVSdhCq4FstiNF7DKrC7ebTxAwLUTb6XK6PvsScUPDcqjxW Zzg2AyE2o0eNwr/RJtUNvWyhdprmLXh81HxKIOxBmN0C40UvnmNjwUy5nTlMMKGxYeBz 3GGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795917653; x=1796522453; h=content-transfer-encoding:mime-version:references:in-reply-to :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=Kr4+CIp0OyMS3P43z0dXIPJU2QAiHr5wTzugTPF8gCI=; b=jA9lRSOCOEsuKN3C5GMiCfyYwga4HBk9uaPZr4EzW/n50oEqW4gSFhuk9mZIzq+dHo Apjc96eyF0eM9+E21S39y+EPzpZNmSz7YT5W/2iFS2XM9wjQ8hkzGliZ165nHgWppQRd kcoVwL0gD/Y2VTPFOsmNg8LWHxWiwSMl6ncdPzBVhbk/u94dYkU/p6k04ZvKzJsuQSvP Jl/w+EgpjPQ+/WpVczVK+7DBfC8KTxuMX7U2vspDIYr/fSS11PQA2TSHVZgZt3uKYX8D +dh9oVDhn3o1ReUDf37x3xCIjcn+WBU7Fawq3ESzPy7BlfAlTZm8MbFOsDwRQCzQGZ2t kkoQ== X-Forwarded-Encrypted: i=1; AL+hErHwsxOAKUNCxz/EGSRsnVNnNvRWqnFDh94UxvSDoa9UXsZwHP4QQ01TdZmi3oQrfiacLAZ6zOo2UeoyY2o=@vger.kernel.org X-Gm-Message-State: APuU4Z/YqM/EUi5qGTg45E3IQlj/6Fp6gcTKMbFI2qgCbqRjaBlYL9t/ hQc4Jm+VOUidGcYg+aBa2EsQw6FB2SzB3q6Sl8iqPWtYGTaaGJsfFkQdTN781/7smEK7cnpQSvh vQUcRgH5Q+tIH2EV8rNsOEjw2lgXpndDJnpClJW8+w9JejQshPDwR X-Gm-Gg: AZFdTZc6OsFoARyNNLZMvrqAHP5DaQ2ANtwecEau6zQ7LOBeNRfOFZ1BY1ysHsG8vJE hugPS9dmWbF4QpOZMa9hrBYrvzLpiad3LLPMKygpUiv1kp+NEjsRwUCapdfQFoJlqnkk1uNondx b8pgTuCX086OxyUe+og6/MHkDW2Klwpm/N+QsMk2dBR1l3pJ2r5w3xcoc6tE5ErYH87nj/nUoxu uJcJSgGh9uZIfL0upOg/Y/AJEybkXdfonEvZ42dUlr98NNMc3bRfPIRYbixRpMFDUWFoeyJZ7VI JXeV0COjfaSVfjF7A7BcycQovpAfAYT2fTGrMFgcLHMu8a3y/ir6e2LuycmCcCz266s/3gZ7xdN +a7zD3xkm11x1rut+dNHWyHyuXvE= X-Received: by 2002:a05:620a:2728:b0:93e:fc4e:c490 with SMTP id af79cd13be357-949ba9c721emr5335840485a.15.1795917652572; Sat, 28 Nov 2026 18:00:52 -0800 (PST) Received: from andrii.ai (mac.hestia.andrii.net. [2602:f337:ed:4865:7374:6961:204d:6163]) by smtp-relay.gmail.com with ESMTPS id af79cd13be357-949bb3de1c9sm246959985a.17.2026.11.28.18.00.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 28 Nov 2026 18:00:52 -0800 (PST) X-Relaying-Domain: andrii.net From: Andrii Tereshchenko To: Steffen Klassert , Herbert Xu , "David S. Miller" Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Christian Hopps , netdev@vger.kernel.org, ipsec@lists.linux.dev, linux-kernel@vger.kernel.org, Andrii Tereshchenko , stable@vger.kernel.org Subject: [PATCH ipsec 1/2] xfrm: iptfs: charge shared fragments to the inner packet's truesize Date: Sat, 28 Nov 2026 19:00:43 -0700 Message-ID: <18d5643f-80ac-426d-9c41-9c23de7ef087@mid.andrii.net> X-Mailer: git-send-email 2.56.0 In-Reply-To: <11df3eb5-b410-41bb-9198-b6c64654d029@mid.andrii.net> References: <11df3eb5-b410-41bb-9198-b6c64654d029@mid.andrii.net> 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 iptfs_skb_add_frags() gives an inner packet references to page fragments of the outer packet and adds their length to its len and data_len, but not to its truesize. Socket receive queues and IP fragment queues then take these packets at a fraction of the memory they pin, and reassembling inner IP fragments trips the truesize check in skb_try_coalesce(). Any host whose large packets cross the tunnel can trigger it, on a receiver whose NIC driver builds skbs with page fragments: WARNING: net/core/skbuff.c:6355 at skb_try_coalesce+0x4bd/0x4d0 inet_frag_reasm_finish+0x12e/0x2e0 ipv6_frag_rcv+0x9b1/0xda0 With panic_on_warn that brings the receiver down. Charge each shared fragment the bytes it references, as skb_segment() does for the fragments it shares; their real truesize is not known here. Made with an AI coding assistant, reviewed by the submitter. Fixes: 5f2b6a909574 ("xfrm: iptfs: add skb-fragment sharing code") Cc: stable@vger.kernel.org Signed-off-by: Andrii Tereshchenko --- Tested in KVM guests with 2/2 on ipsec master: without this patch it trips the warning and finds a socket charged 1.9 MB for 2.9 MB of queued datagrams; with it and panic_on_warn=1 it passes, two boots each way, with lockdep, KASAN and UBSAN clean and xfrm_policy.sh / xfrm_state.sh passing. Under KCSAN-strict it reports nothing beyond the unpatched baseline (tick_nohz boot noise; nothing in xfrm). The proposed IP-TFS KUnit tests cover this too (iptfs_add_frags_test and two more). Found by an AI code review agent. Validated with the 2/2 selftest on ipsec master, no kernel change or fault injection. Tested against that selftest. net/xfrm/xfrm_iptfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c index 0313a43aa8a97..0b9642208c71f 100644 --- a/net/xfrm/xfrm_iptfs.c +++ b/net/xfrm/xfrm_iptfs.c @@ -460,6 +460,12 @@ static bool iptfs_skb_can_add_frags(const struct sk_buff *skb, * that the destination @skb is compatible with the walk and has space in the * array for the to be added frag references. * + * The truesize of the source fragments is not known here, so @skb is charged + * for the bytes it references, as skb_segment() does for the fragments it + * shares. The source keeps its truesize: from here on it never enters + * socket, fragment or qdisc memory accounting, so the bytes are charged + * once. + * * Return: The number of bytes not added to @skb b/c we reached the end of the * walk before adding all of @len. */ @@ -495,12 +499,14 @@ static int iptfs_skb_add_frags(struct sk_buff *skb, tofrag->len = len; skb->len += len; skb->data_len += len; + skb->truesize += len; return 0; } /* advance to next source fragment */ len -= fraglen; /* careful, use dst bv_len */ skb->len += fraglen; /* careful, " " " */ skb->data_len += fraglen; /* careful, " " " */ + skb->truesize += fraglen; /* careful, " " " */ walk->past += frag->len; /* careful, use src bv_len */ walk->fragi++; } -- 2.53.0