Article View: linux.kernel.netdev
Article #9041Re: [PATCH net 1/2] net/ipv4: reserve exthdrlen as headroom instead of counting it in skb->len
From: Willem de Bruijn
Date: Fri, 30 Oct 2026 22:23
Date: Fri, 30 Oct 2026 22:23
68 lines
13783 bytes
13783 bytes
tencentos_secure(TencentOS安全公共邮箱) wrote:
> When sending through an xfrm route (rt->dst.header_len > 0),
> __ip_append_data() counts the bundle header space ("exthdrlen")
> into skb->len of the first fragment skb: the skb setup does
>
> skb_reserve(skb, hh_len);
> data = skb_put(skb, fraglen + exthdrlen - pagedlen);
> skb_set_network_header(skb, exthdrlen);
>
> so a fully filled first skb has skb->len == maxfraglen + exthdrlen.
> Since commit 353e5c9abd90 ("ipv4: Fix IPsec slowpath fragmentation
> problem"), the next iteration's fraggap = skb_prev->len - maxfraglen
> therefore inherits the whole bundle header length instead of the
> intended alignment slop.
>
> fraggap is relayed into the next skb by skb_copy_and_csum_bits(), but
> the MSG_MORE (alloclen = mtu) and linear (alloclen = fraglen) branches
> account for fraggap in the allocation only for as long as datalen stays
> uncapped. Once datalen is capped at maxfraglen - fragheaderlen, the
> bytes copied into the fresh skb exceed the skb head allocation and run
> past the end of the buffer, corrupting skb_shared_info. The
> paged-branch accounting of
> commit eca856950f7c ("ipv4: account for fraggap on the paged
> allocation path") relies on datalen accounting for fraggap, which
> stops being true exactly when datalen is capped.
>
> Fix the root cause by reserving exthdrlen as headroom, like IPv6 has
> done since commit 1f85851e17b6 ("ipv6: fix incorrent ipv6 ipsec
> packet fragment") in 2012:
>
> skb_reserve(skb, hh_len + exthdrlen);
> data = skb_put(skb, fraglen - pagedlen);
> skb_reset_network_header(skb);
>
> With this, every fragment skb satisfies skb->len <= maxfraglen, so
> fraggap <= mtu - maxfraglen <= 7 (the alignment slop the relay was
> designed for) and the copy destination is provably in bounds.
>
> Allocation sizes, tail positions, tailroom and truesize are unchanged
> (alloc_extra already carries exthdrlen), and when dst.header_len == 0
> this is a literal no-op.
>
> Fixes: 353e5c9abd90 ("ipv4: Fix IPsec slowpath fragmentation problem")
> Reported-by: TencentOS Corvus AI <corvus@tencent.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Anakin Zhang <tencentos_secure@tencent.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
On taking another look, it is easy to see that
- this only affects XFRM paths, and then only the first skb
- only data and len fields are affected
- data is still at the same location
Technical Details
Message-ID:
<willemdebruijn.kernel.18765b89651aa@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353978-linux-kernel-netdev=dewy.ruReferences:
<v2-20261026-cover@tencent.com> <589B4474E0A78486+v2-20261026-p1@tencent.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353978-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/2] net/ipv4: reserve exthdrlen as headroom instead
of counting it in skb->len
Date: Fri, 30 Oct 2026 18:23:01 -0400
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.18765b89651aa@gmail.com>
References: <v2-20261026-cover@tencent.com>
<589B4474E0A78486+v2-20261026-p1@tencent.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="2324487"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:g0moJ8NNLrmkwgnEW7T9eCkNOdA= sha256:h+zEBimCBRE7uF5kRMans5c6zzqJ2nhfMhDZCkuj6+I=
sha1:KN2q6H56UePdS/OejCus6dZqGlE= sha256:yMN0W5CkHDESelZzZEMyaRgSpvrAn0/r+Ph1xPMsZ6w=
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 F1771125CAC; Sat, 31 Oct 2026 01:23:26 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
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=gmail.com
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 b29lO1VrIvdK;
Sat, 31 Oct 2026 01:23:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353978-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 7070D125CA6; Sat, 31 Oct 2026 01:23:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id D2AAB275BF; Fri, 30 Oct 2026 22:23:04 +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=1793398984;
b=K5r7nBKjafDm7jKPgPdNBAVUkLnb0b3aMMJRhEuP7+4tPNqSnqxwvLzXdzXwZ8dMeahG
NqesvPfv3B58oojhZ9rX8b5PsUYzs2Q5Ho6+8r5IUhN0gv4vlaL2k0ZUcVZ5p9D3c/g5U
wPdSVinh+CInw+lfNyheyaBSBke0cI1xp2vd/I+1eEeJZq0TqrA9rTg3ITeD7m7DMjh0S
KXcUl0EwRCDjhOnTcLZUF36fRjC2vldwvRNy01UVvhJ1YyXPouFbnDoRWJINoZpeqAEAM
DEUfKYEG4HfYT/HU/POtdYqlq6nygl2BTphhkU+2nTxAIRfpjbw1mA+fIVRJzpBa0uA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793398984;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Message-ID:In-Reply-To:
References:Subject:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Type:Content-Transfer-Encoding;
bh=Z8xLH8tphg/sJCScdh+9RwuO0WOmq7EM7GVsYTwxod0=;
b=BV/cF6bzM6xWtWwFSH7gwED2sWaIf2G96Ip/4HfH3HLrTi7w8pkCnpXdUCQyVWbW2SPN
rotkJzMWLTJD36jc/wAeLSiiZR8M83PxPKaB0yeq4TBESb7BGKNJgws7ryOAvLssGdEnE
3sGtJX6giSL+71VLO6m7z7rjatQ02XIRFtLn+9CSOPtiYosg7DdC6zspjaENXB8BgcReO
shoHlzVkLdV80LcmxNg7U/YDen7A2mtaNtHWR1qkmUs+VGp2wMyv0h+mBh6XHuBjaMkwB
gJFOht1LCAJlM2Za2VeL8PikwG6C31456+cKdNn2v+lY6WbQn5iLjG2rdm1llt88uYA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NyOhzez6;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 A79D9606A321;
Fri, 30 Oct 2026 22:23:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NyOhzez6
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.217.44
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793398983;
b=Nq7FpFOTgmvUvho530sOYCqPt1mrq1GgWch6IOandsDXpQKiToepT9uvhLPJGr4PTPzz
Xaj7ZfvlxH82pY1Ph3HRgZPf6KYNQH05HG16QG7ys6977temKRBekuCdUq9PKHgvbEhhz
dVqTlLnqSRonw7Zt2HKpMT+XMCXO0SK3gQh1NHsvni89629Fx22Ni0nVVroxzrPKznyAu
pwXUvLj+sGhuzQbzcPtj6EMLm+TWPi+faCSUFj/UApDm8SfLnSPmBRodtfuinB0IpBMK1
3BHVcR+t2zRrptYc7hKZzkcz5yUC6ahflhMDhHpbQqKmWGMQZsh6VUPLfhWG5tyWSpw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793398983;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:
MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=Z8xLH8tphg/sJCScdh+9RwuO0WOmq7EM7GVsYTwxod0=;
b=0FcHmmneMqr3RuPLyY1yXvio6zUXyANv2S4cEkkEsgxCXsyRFSM9YFlzap9ewMfqZal2
jnMOT2D3VdCJqFkbZnMPSXTRuOnrBsiPinlYDXIpzndv87s9soM9GgzfLp+izcF6TyNC3
4C4hiaxdM8c8F7vjn8S6LIl/PSajNa5XSZM49CyjrrHtY8v3hAizyEBWhZluGCsHL8c3q
y83v5CqQJ7R0JEqt1kcNZO95C30hkI3LzAKOeqElLcKLi9oanwporHaJFTKmTm7xWyA9G
Zj6Rm0NwMiE794Cju/s9AkP6jLq3dqnYb1fKFz4iTWaZ0haqC8Sj6JYI3mqmXbwi49g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NyOhzez6;
arc=none smtp.remote-ip=209.85.217.44
X-Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44])
(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 7144A606A31C
for <netdev@vger.kernel.org>; Fri, 30 Oct 2026 22:23:03 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7144A606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-vs1-f44.google.com with SMTP id ada2fe7eead31-7c03744ef27so399719137.1
for <netdev@vger.kernel.org>; Fri, 30 Oct 2026 15:23:03 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793398982; x=1794003782; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=Z8xLH8tphg/sJCScdh+9RwuO0WOmq7EM7GVsYTwxod0=;
b=NyOhzez60cdEJZkj3a1Ki0i9NX0+5oiPG8c0KX992RZv9xmU4iezyGrAoxDPDa50Pr
5N42/UdFZtTzgL7gNmxMaTfbC1DOw5ijS+q+Jy+uhFA1baTHESJSaFe2LcTrcWfWZcHr
APlC0pKZN5vcfRv9y2tpHgUsdqz8QRDra9UccLaUHiYe6cpolBjgamTZIcBQCsnL6QqS
tJxaVU3GCDxNXBgXufmria6jQCHo58cccEDBNZwGExLutHNvHXhkuzioHKEGlP46rqoh
FGAD4Ud2RxPInl4w7sBsnFNAVk3Td7Cu/wC9TNAQcI8HkLVhYaRhuLoLim92Oo58wjc0
U/7A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793398982; x=1794003782;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=Z8xLH8tphg/sJCScdh+9RwuO0WOmq7EM7GVsYTwxod0=;
b=OrJf62nOeIbLIu4kAh2Oc70jKMXbaO6ocG2QjxgLbuWolQ50ZKpcjVfasSPRpfCo1Z
mb9yVAeRdUex50QWp70ncUJMGUPsbzSX5WroA0jHlyQRNA8YfQ4HsU2u38fsQhoUXbVM
YvvKlq/DCx7w9bVU0rE80dtHV0DHXPR7DGck5qD0EOikcN+5eqfhbf/46Jl7oLnTD/MZ
jYG4P2VzPXj1fREwMURGvNZs4Kog4ZLzArLXNrvs40Qhk1GeKDtmigY7WUh8Oon8uek5
I23tgJ3iB3BSYhJoKrQrB4NHkurmfuHdq0QuZINIjmAdftjS0MVpsBRJFPNuj+z/qMEZ
HU7g==
X-Forwarded-Encrypted: i=1; AKwUvBxajvqJj1W1aJ+SqLDriqNVXSvklIy9nrXMEuRFxh1ljl2sYBkeLGpe8ee46GCOP3SM0mSmfEY=@vger.kernel.org
X-Gm-Message-State: AFq9FYKfccDd9eWveP4g5xmVpviUEH8iObpfo01ngCUPUWTr4bWVubHj
3juLg0HmhKeUKB9yKr4VHBQWgPyslkzfhnE0RCj/8NUuRaWNXSX7WjBWeieavA==
X-Gm-Gg: AYBFou3XynULLcWxd4rCL2DkI8Y4bzGo2awIfYJGRpwkGMGZSVWx5/qCGnpdb+VHNqZ
dS+WpDvaHpedPZzSZ0uI1BsyAfZ+JuKXEVzdGnDsBpSLblR48qKXx6DKKauP3HbvoKFJcSmoDe1
VqcFsjVIXOwGEMfIkzIfe6QP7Eg/k1GsBM97ps5TXtT/6vZMSV7Eyl/EO6uxbv5LI4iehFTGwFU
zewoQnDICy+FSBjX6zTsXO5aECXct4jlTmcSQorZktZMvHIQppwvrZN3FmM/FuieJEqZ28VU7bO
wYuzkw05uQgoCEIgY1BW+jGBHhxM5DLYdpKEZt48yXQyGmrnQOLBWPgAECRXZS/lSyA236ARytQ
Mn8SoqQfJVcCCQCwHUhPjoqPRgXqZwBfkMiNOratvY/dY33hRITvsKhab4n7Aa1+jk619OOvt6x
K8VdGGitQGte1uPwJLGf/I+bROMb6B/pPGUg566O93en0sRuOvTfUUvtU+NbSqvNDLdnoevAZrC
6Cqmm+14mAcTzPiLEzCzUjgpPlsBY/WeWbeLFZA491IOcPpZw1pp3ZeeO2GDjkWeDwS4uB2W6Qo
8IshaJJy9m2y2XGP9r9Fv5R7rcZeOm7r6Esh3AHeK1qcWnhcZ3ZBT1ikXDhb3R5/XbfWySwNFk7
/AqXJ1EMPLScJ23UxQPb21Fq8ll8hlSioQNRN/47ptumSKcCjRh+vgYOK8wB8QRkZjqe+
X-Received: by 2002:a05:6102:9d4:b0:7ce:5952:125d with SMTP id ada2fe7eead31-7d0728d38cemr1656784137.36.1793398982417;
Fri, 30 Oct 2026 15:23:02 -0700 (PDT)
X-Received: from gmail.com (111.46.245.35.bc.googleusercontent.com. [35.245.46.111])
by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-992ee4c1603sm4219115241.10.2026.10.30.15.23.01
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 30 Oct 2026 15:23:01 -0700 (PDT)
X-Cc: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
Paolo Abeni <pabeni@redhat.com>,
Jakub Kicinski <kuba@kernel.org>,
Willem de Bruijn <willemb@google.com>,
Steffen Klassert <klassert@kernel.org>,
Eric Dumazet <edumazet@kernel.org>,
security@kernel.org
X-In-Reply-To: <589B4474E0A78486+v2-20261026-p1@tencent.com>
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