๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #337

Re: [PATCH net] calipso: update payload_len when removing the CALIPSO option

#337
From: Eric Dumazet
Date: Wed, 07 Oct 2026 20:45
76 lines
9368 bytes
Le mer. 7 oct. 2026 ร  17:26, Joas Antonio dos Santos
<joasantonio108@gmail.com> a รฉcrit :
>
> calipso_skbuff_delattr() removes the CALIPSO option from the hop-by-hop
> extension header, or the whole extension header if CALIPSO is its only
> option, and pulls the skb by the removed length.  It never updates
> ipv6hdr->payload_len, so after a successful removal the header still
> claims the original length.
>
> calipso_skbuff_setattr() already adjusts payload_len by the length it
> adds; the delete path was missed.
>
> This is reached on the forward path when a packet carrying CALIPSO is
> sent to a destination mapped to an unlabeled NetLabel domain.  The
> forwarded packet then has a payload_len larger than its real payload
> by the removed length (8 to 264 bytes), and the receiver drops it as
> truncated.
>
> Adjust payload_len after the header is moved.
>
> Fixes: 2917f57b6bc1 ("calipso: Allow the lsm to label the skbuff directly.")
> Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
> Assisted-by: Claude:claude-opus-5-5
> ---
> Found by code review.  Compile-tested only (arm64, W=1); not runtime-tested.

The analysis looks right to me, but this means removing the label on
the forward path has been broken since 2016 for every packet that is
not resegmented later (SYN, UDP, ICMPv6...).

For a patch targeting net and stable, we would really like to see it
exercised at least once. Please run a forwarding setup with an
unlabeled destination (the NetLabel tests in selinux-testsuite could
be a starting point) and describe what you tested in the changelog.

>
>  net/ipv6/calipso.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
> index c6a34334e..c072eca50 100644
> --- a/net/ipv6/calipso.c
> +++ b/net/ipv6/calipso.c
> @@ -1428,6 +1428,9 @@ static int calipso_skbuff_delattr(struct sk_buff *skb)
>                 skb_pull(skb, delta);
>                 memmove((char *)ip6_hdr + delta, ip6_hdr, size);
>                 skb_reset_network_header(skb);
> +               ip6_hdr = ipv6_hdr(skb);
> +               ip6_hdr->payload_len =
> +                       htons(ntohs(ip6_hdr->payload_len) - delta);

This is not correct for BIG TCP.

GRO can aggregate TCP packets carrying identical extension headers,
and ipv6_gro_complete() uses ipv6_set_payload_len(), which stores 0
when the packet is bigger than IPV6_MAXPLEN.

For such a forwarded packet, the above would write
htons(65536 - delta), and ipv6_payload_len() would no longer fall
back to skb->len. nf_tables, conntrack and sch_cake rely on it.

Something like this instead:

ip6_hdr = ipv6_hdr(skb);
/* BIG TCP packets have payload_len == 0 */
if (ip6_hdr->payload_len)
be16_add_cpu(&ip6_hdr->payload_len, -delta);

calipso_skbuff_setattr() has the same issue with its
htons(payload + len_delta), this can be addressed in a separate patch.

Thanks.
Technical Details
Message-ID: <CAL4WiirbJrQThGS4BUo=a=AV9ckJk2AyedO8AgJgozjHOwu5Vw@mail.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-342536-linux-kernel-netdev=dewy.ru
References: <179138670045.80227.16292613517250896744@gmail.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-342536-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] calipso: update payload_len when removing the CALIPSO option
Date: Wed, 7 Oct 2026 22:45:21 +0200
Organization: Usenet Network
Message-ID: <CAL4WiirbJrQThGS4BUo=a=AV9ckJk2AyedO8AgJgozjHOwu5Vw@mail.gmail.com>
References: <179138670045.80227.16292613517250896744@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="735861"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:AV13iZH3AD00mxphbl9A0PsTbrk= sha256:se29uTtaEXfOjuU0cuaF0DraznErQkk1xwlnz2bPrx0=
	sha1:Xlp8WLTZBFI4tCiZpZv8Wb3o9x4= sha256:9y7ED99TrZ5Ftkb2xig5ocYUZAYeTh+w1p2DvkiQXYk=
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 1D9AF10F246; Wed,  7 Oct 2026 23:52:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.641
X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, 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 SO1tZEazAo4T;
	Wed,  7 Oct 2026 23:52:11 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-342536-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id BA18110EE3E; Wed,  7 Oct 2026 23:52:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 5A0343D141; Wed,  7 Oct 2026 20:45:54 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A1C753DB626;
	Wed,  7 Oct 2026 20:45:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SGDn3ug8"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 866853D6690
	for <netdev@vger.kernel.org>; Wed,  7 Oct 2026 20:45:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791405934; cv=none; b=tcYjGP9hKS7WOU+KAskABDfJMvDux6KMw79dz2sUpBvJHShD3qMhdptEcf28bgQHL3Thl+Uv5Y0G8R6hnuSZasblZO3k/gmsKT80jgTrGjOYkwenJh5aV8ZhbnGg1ZuWeWstKAw/3CcB1B+kNI/1SpNH8Qo7TiW9yLBwIEVDXh0=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791405934; c=relaxed/simple;
	bh=XklnFHmbHQS7VZkDuG150iHCHuym7kKaiF9qMmPfxWk=;
	h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:
	 To:Cc:Content-Type; b=ijjtJN9BfWnDjnbdXsQ3IIuPujox3cjWwu8d/If9UOrV1hdJY/UN4DF8mfGdIKXSxTFYZs8uHKvHqWu88+atuqGIdSHe4xdjh69DZMqROQnoiPV4GXwvZrY1ytta6Gb15ezeM1Rjwukc6yJNhA8eziEQs7ocZgou2MCiqHzHqaU=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SGDn3ug8; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69A621F0089B
	for <netdev@vger.kernel.org>; Wed,  7 Oct 2026 20:45:33 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1791405933;
	bh=vH1JfG3bndKx8TMAH3C7J9XtsPB7MG47a4kraAsYAVA=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=SGDn3ug8Ut0TqoATGFX6VVPqLPozQOAOEtm1SFimcttB2+db5sxEUbAo2zQmFXREW
	 U+ArjwD5yt7tVJdeTFk8haRWsPZh4CDfRwnYlFm4jQ/NPEzizFK1ylZppRcO02k1zt
	 GgdboDvL+mXpNQksyJNkVu1hUtPJyGiNJFGUyfODolz/zIhpawuTOpkjANksLESxPX
	 pwAP9+B/6gi5LlHxeU9dXGQ/IUOfoofBBqfz5t4wmj0EzPlleebel/NTebsuKkA+TH
	 dyHER3vJFzom+r6OpfOV/2Jyj79L85KNi8LvPWSktViRY/yN5MMDmSrkOYu0TLIuTk
	 zOZcu8jBlaCTQ==
X-Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-48e94879f02so897399fac.0
        for <netdev@vger.kernel.org>; Wed, 07 Oct 2026 13:45:33 -0700 (PDT)
X-Forwarded-Encrypted: i=1; AKwUvBwu2GNbLdqAvc5NZp7XjIwr/YHapxBHazQ+RYbmGfSmG7iZzp4ngNP1YXNe6lhR1pf4QrUbqIk=@vger.kernel.org
X-Gm-Message-State: AFuF++nzGHSrxuv9CDYSLAKMXHMOKsEyIp8t40yntD2uHofSTK0bVm4x
	u4hRpyfN6fA6GbDeeFr5xMQCC26RgYAaeSDRM4172Y4o0YEsRyENcaZYcGs/sr26TyhPU3JIz8v
	LGDdGgyN0K4WV1a31+hwgT4pL8RPn0LQ=
X-Received: by 2002:a05:6870:891d:b0:48f:e0f6:c45e with SMTP id
 586e51a60fabf-4a2596a2130mr3260410fac.44.1791405932610; Wed, 07 Oct 2026
 13:45:32 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <179138670045.80227.16292613517250896744@gmail.com>
X-Gmail-Original-Message-ID: <CAL4WiirbJrQThGS4BUo=a=AV9ckJk2AyedO8AgJgozjHOwu5Vw@mail.gmail.com>
X-Gm-Features: AclHuK_2K5aXaZQQbDLyAem3QMNCwXVR5Lav3TazV6a0LVSPtYk80Kv8XKrwBkg
X-Cc: Paul Moore <paul@paul-moore.com>, "David S. Miller" <davem@davemloft.net>, 
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, 
	netdev@vger.kernel.org, linux-security-module@vger.kernel.org, 
	Alice Mikityanska <alice.kernel@fastmail.im>