Article View: linux.kernel.netdev
Article #25297Re: [PATCH 01/22] xfrm: ipcomp: account full fragment pages in truesize
From: bot+bpf-ci
Date: Tue, 01 Dec 2026 13:36
Date: Tue, 01 Dec 2026 13:36
76 lines
10497 bytes
10497 bytes
--===============4829894544344312686==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
> xfrm: ipcomp: account full fragment pages in truesize
TL;DR: In ipcomp_post_acomp(), the truesize increase may unbalance the
sender's sk_wmem_alloc for skbs arriving via veth and ESP GRO, possibly
underflowing it or freeing the socket early; the patch enlarges an existing
mismatch.
> diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
> --- a/net/xfrm/xfrm_ipcomp.c
> +++ b/net/xfrm/xfrm_ipcomp.c
[ ... ]
> @@ -67,7 +67,7 @@ static int ipcomp_post_acomp(struct sk_buff *skb, int err, int hlen)
>
> /* Only update truesize on input. */
> if (!hlen)
> - skb->truesize += dlen;
> + skb->truesize += PAGE_ALIGN(dlen);
> skb->data_len = dlen;
> skb->len += dlen;
Can this truesize write unbalance sk_wmem_alloc of the sending socket
when the skb arrives through the ESP GRO path?
The input branch assumes the skb is not charged to any socket. On the
ordinary xfrm4_rcv()/xfrm6_rcv() path the skb was already orphaned in
ip_rcv_core()/ip6_rcv_core(), so that holds.
But a local UDP or raw sender's skb carries the sock_wfree destructor, and
the following path keeps it:
veth_xmit()
veth_skb_is_eligible_for_gro() accepts skb->destructor == sock_wfree
__dev_forward_skb() -> skb_scrub_packet() does not orphan
veth_xdp_rcv_skb()
skb_prepare_for_gro() only orphans when destructor != sock_wfree
napi_gro_receive()
inet_gro_receive() -> esp4_gro_receive() -> xfrm_input()
ipcomp_input() -> ipcomp_decompress() -> ipcomp_input_done2()
ipcomp_post_acomp(skb, err, 0)
skb->truesize += PAGE_ALIGN(dlen);
The skb is still charged to the sender at that point. Later ip_rcv_core()
calls skb_orphan(), and sock_wfree() subtracts the inflated skb->truesize
from sk_wmem_alloc, which was only charged with the original value.
Each such packet over-subtracts PAGE_ALIGN(dlen) from the sender's
sk_wmem_alloc, which can underflow the refcount or drop it to zero early
and run __sk_free() while the socket is still in use.
The same hazard existed with the old "+= dlen", but this patch enlarges
the mismatch by up to PAGE_SIZE - 1 per packet (about 64K on 64K-page
kernels).
pskb_expand_head() guards this kind of change:
if (!skb->sk || skb->destructor == sock_edemux)
skb->truesize += size - osize;
Would gating the input adjustment the same way keep the receive-side fix
without touching a sender's wmem charge?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46652847109
--===============4829894544344312686==--
Technical Details
Message-ID:
<a4af8e909915288698495338b4bb19a521b495e32680681d90d4a5db56a48bc0@mail.kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375115-linux-kernel-netdev=dewy.ruReferences:
<20261201124252.1163254-2-steffen.klassert@secunet.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375115-linux-kernel-netdev=dewy.ru From: bot+bpf-ci@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH 01/22] xfrm: ipcomp: account full fragment pages in truesize Date: Tue, 1 Dec 2026 13:36:21 +0000 (UTC) Organization: Usenet Network Message-ID: <a4af8e909915288698495338b4bb19a521b495e32680681d90d4a5db56a48bc0@mail.kernel.org> References: <20261201124252.1163254-2-steffen.klassert@secunet.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4829894544344312686==" Injection-Info: usenet.network; logging-data="1723550"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:07dn9vFLnDJsNOCuFBsVIYSXh3k= sha256:R4DS8F9Ms+UTiQszkvDAVmuNwpIvuyO2Jykymg380e0= sha1:e7G+YFX7QSh/vqQ3X+o/6DuXaDw= sha256:DvrcYQ1mgsxiqBosWFTd+ulTj0iXvb8/qzduZdgI6N8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D94341173BD; Tue, 1 Dec 2026 16:36:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SoBySPtnvBQl; Tue, 1 Dec 2026 16:36:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-375115-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 367E11173BA; Tue, 1 Dec 2026 16:36:30 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id EF6F76024FF; Tue, 1 Dec 2026 13:36:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796132184; b=cRdXCNMXb5Y0JY6+D0IPvdosV2mEeAAJmEJIuQhmkfopoHj8QafcWRlzk+kSQa0o/dtx X4wx6+yEwWnYv0cDzGDii8w15Ixbacmy9ZrF5tDzaEmYNKYIf6crXFE6c27lqcwUAhDYX Py2Et0mR3wycq9MNjqXF/jEjhoP0rw0T0xM+f56v2Akp9tALx8q54T4FdnTMU1hWsAQai 19fMtyIvuR2UnQNped2zJobWXLBkzP6dey0Z+bjZUPqAeGBN28sGVqTHsyn+a9tMGCTg5 YwE+Y39zD+PjjbUzMWZ919myc2BwQI+VoSejVg0qosWho7ZXiMQxqCIaW7oUIrdmgJw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796132184; h=X-Original-To:Received:Received:DKIM-Signature:Content-Type: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=AG7gnJbzszilqY1rCzkTSLK6ukc28k0N4OcL7qOr0xs=; b=yD6bXFshZs8piG/oHDO2vYzrl09UGSRsVJZFgOrMOudKZIhw9mk2yWp1PrV2zRKjexAR 4uH1rB9yNMWOjBmlMTNU2DQCsEH87ZhsFwAlTehRz5f48p4TLZeYZetNM7dCGF/LlWJ3y q0/Hauxz7mjOMOn6MuJi2pP+iqZ7wdCsI5OqqMsrWldFkvJRmw+PYyuVgzWZ1vo37RI7C t3iNka73YqDlFJuJ94NPX2y+3s7qc3Ycj8nGJCrfVHehMMwcBWWA70fjH2ITif4yJ49dA ryHxOT4SIdoAvr8StR5LbevH+9SsTbHsbsWQdDoEBcQsU6yDVU+246w0VXMgvel9wUQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E4JJoZJ1; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 447C2606A325; Tue, 1 Dec 2026 13:36:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E4JJoZJ1 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796132183; b=bAIrdpwMhph9Ues4wjC7rHv/iToiW0cqdWS6TyuTTgk/ZMLz+bNkuVvysc0uOhfX/VWP wj9fiKN7vA7GQZLD4YNt4Pp9yaTztB/xMvO1K5xo1mLS8sFJZWNpIDk3EgMFxYMeRb+i7 3H3qn1M9O05xkHdHZiyh5beaL55aEyhcP7yEl/GZH6lyJoiPEOUm3k3J9aBTQLHbdAO+b bzET0qKtjaJko5IRY+kZCc7rzQrhgYNUXcYawwhwWt3B1oDghKCc5WQIIrhWaL/obJliJ vX//pEqZRKrhW3qbQeMPXsUyMM5fPTiEI8rgmM+nMACSLeWOTgYHJnRPsJxcNl8fG3A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796132183; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=AG7gnJbzszilqY1rCzkTSLK6ukc28k0N4OcL7qOr0xs=; b=ysB38czA6dWCvTzmiQVCSBegaQzv7apRMp6F2jwM/sKAZQjgLm8ctyIpqzgV8s3vPpxI xHfAXL5GxdjVlXSEZ8YoPzoG8/qb1KBvjp7VxFHuN05JmxdHeWFadYmXutu0amnWRuo3N RNgdmK9h3dAocDgSCtnfJtPH8WGGR1n4q+wtE5vkgi4vFea2ZavHtA2uicv6oeOFVA6nC s69LUEgAyOMvgejf98ft9ymj/aY5adWcnt2zwq73LZguq1cZK6jRUx70Lj/tJN9fMY2IX spRMvrZ5miXWJQgiUuNkKgtlh1DIXTrc/2gMzeICP/bcrSrUv26aFnLvuton9ba4bOA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E4JJoZJ1; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66A5E606A327 for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 13:36:23 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C2CA1F00929; Tue, 1 Dec 2026 13:36:21 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796132182; bh=AG7gnJbzszilqY1rCzkTSLK6ukc28k0N4OcL7qOr0xs=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=E4JJoZJ1tIF0+YBrqAX0BVZ95c8FGhz19ZLthU0wumgVmzTmG6ucdRJkcJ7cqpCfI FFIAMpW0Ub1nl71/j2r7xPxfyb70N9EQCeSUNrdGxWynfmQzGulGgW+gsBwjYVkQL3 UPs5R7DIXiz+qOV+YI7LJDZ9BiKWg1Ngme08hrH3lfkuLhQFzw5n2wYDu/UkzmEEEo X4aPVFFTJce9QeUfyC83hOQtRJ8CZWN8mCZ16keXRTW3MOsILJ3zR2bI2GdQPU4Wvm 4GtAKOPvu0k078TWXSX/J46n5uj62oYVXe9MSBw0O7CKAIrL4dx37UBb/L9/rjzQu/ RbvvytXaSAmug== X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261201124252.1163254-2-steffen.klassert@secunet.com> X-Cc: herbert@gondor.apana.org.au,steffen.klassert@secunet.com,netdev@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev