All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v2 04/15] ms/calipso: keep BIG TCP payload_len in calipso_skbuff_setattr()
Date: Tue,  1 Dec 2026 14:10:19 +0200	[thread overview]
Message-ID: <20261201153749.2872789-5-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261201153749.2872789-1-eva.kurchatova@virtuozzo.com>

From: Joas Antonio dos Santos <joasantonio108@gmail.com>

[ Upstream commit 8070ed578b6b9134e045627fb745c887a806d46e ]

calipso_skbuff_setattr() adjusts payload_len by the length of the
option it inserts or resizes:

	payload = ntohs(ip6_hdr->payload_len);
	ip6_hdr->payload_len = htons(payload + len_delta);

GRO can build BIG TCP packets larger than IPV6_MAXPLEN, and stores
payload_len == 0 for them; ipv6_payload_len() then falls back to
skb->len.  For such a packet forwarded to a destination mapped to
CALIPSO, the code above writes len_delta (or 65536 + len_delta when
shrinking) into payload_len, and ipv6_payload_len() no longer falls
back to skb->len.  nf_tables, conntrack and sch_cake rely on it.

The same arithmetic also wraps when a packet grows past IPV6_MAXPLEN,
and a BIG TCP packet that shrinks below IPV6_MAXPLEN should get its
real length back.

Set payload_len from the skb length with ipv6_set_payload_len(), which
stores 0 above IPV6_MAXPLEN and the real length otherwise, as
ipv6_gro_complete() does.  The network header was just reset to
skb->data, so skb->len - sizeof(*ip6_hdr) is the payload length.

Tested on one kernel (arm64, QEMU) with SELinux permissive, a minimal
mdp-generated policy (network_peer_controls=1), "netlabelctl calipso
add pass doi:16" and a NetLabel mapping of fd00:2::/64 to CALIPSO
DOI 16.  calipso_skbuff_setattr() was called through
netlbl_skbuff_setattr() from a test-only debugfs hook (not part of
this patch) adding a level-only label; payload_len after the call:

  case                         before fix   after fix   real length
  1000, unlabeled                    1016        1016          1016
  70000 GSO, payload_len 0             16           0         70016
  65530 GSO, grows past MAXPLEN        10           0         65546
  65540 GSO with a 24 byte hop
  header, shrinks below MAXPLEN     65528       65532         65532
  1000 with a 24 byte hop header      992         992           992

(0 means ipv6_payload_len() returns the real length.)  On the forward
path, with a client injecting unlabeled UDP through a router to a
server, the router adds the CALIPSO option and the server delivers all
datagrams (Udp6InDatagrams 5, Ip6InTruncatedPkts 0) with this patch.

Fixes: 81fbc812132c ("ipv6/gro: insert temporary HBH/jumbo header")
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Suggested-by: Wang Zhan <wang.zhan@smartx.com>
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Assisted-by: Claude:claude-opus-5-5
Reviewed-by: Wang Zhan <wang.zhan@smartx.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://patch.msgid.link/179156155963.36253.400481753322266658@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 929dc8e2c9165bb651dca26b2c68067a3880406b)

https://virtuozzo.atlassian.net/browse/VSTOR-157577
Feature: fix ms/net

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
---
 net/ipv6/calipso.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index 86b9734c0715..f9c809266445 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -1315,7 +1315,7 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
 	struct ipv6hdr *ip6_hdr;
 	struct ipv6_opt_hdr *hop;
 	unsigned char buf[CALIPSO_MAX_BUFFER];
-	int len_delta, new_end, pad, payload;
+	int len_delta, new_end, pad;
 	unsigned int start, end;
 
 	ip6_hdr = ipv6_hdr(skb);
@@ -1354,8 +1354,8 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
 			sizeof(*ip6_hdr) + start);
 		skb_reset_network_header(skb);
 		ip6_hdr = ipv6_hdr(skb);
-		payload = ntohs(ip6_hdr->payload_len);
-		ip6_hdr->payload_len = htons(payload + len_delta);
+		/* 0 above IPV6_MAXPLEN (BIG TCP), the real length otherwise */
+		ipv6_set_payload_len(ip6_hdr, skb->len - sizeof(*ip6_hdr));
 	}
 
 	hop = (struct ipv6_opt_hdr *)(ip6_hdr + 1);
-- 
2.56.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-12-01 15:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:10 [Devel] [PATCH hci-8.2 v2 00/15] ms: backport additional TFO and CALIPSO fixes Eva Kurchatova
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 01/15] ms/tcp: clear sock_ops cb flags before force-closing a child socket Eva Kurchatova
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 02/15] ms/tcp: Skip cond_resched() in inet_csk_listen_stop() under BPF context Eva Kurchatova
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 03/15] ms/net/ipv6: Introduce payload_len helpers Eva Kurchatova
2026-12-01 12:10 ` Eva Kurchatova [this message]
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 05/15] ms/calipso: hash the cache key, not the option start, in calipso_cache_add() Eva Kurchatova
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 06/15] ms/calipso: update payload_len when removing the CALIPSO option Eva Kurchatova
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 07/15] ms/tcp: fix NULL pointer dereference when restarting a Fast Open listener Eva Kurchatova
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 08/15] ms/tcp: purge Fast Open RST queue when listen() fails Eva Kurchatova
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 09/15] ms/netlabel: fix IPv6 unlabeled address add error handling Eva Kurchatova
2026-12-01 15:42   ` no-reply
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 10/15] ms/netlabel: validate unlabeled address and mask attribute lengths Eva Kurchatova
2026-12-01 15:42   ` no-reply
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 11/15] ms/bpf: Fix out-of-bounds read of sk_protocol in bpf_sock_destroy() Eva Kurchatova
2026-12-01 15:43   ` no-reply
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 12/15] ms/selftests/bpf: Test bpf_sock_destroy() on TIME_WAIT and listener socks Eva Kurchatova
2026-12-01 15:43   ` no-reply
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 13/15] ms/tcp: initialize send sequence numbers before deferring TFO Eva Kurchatova
2026-12-01 15:44   ` no-reply
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 14/15] ms/cipso: fix optlen corruption in cipso_v4_delopt() Eva Kurchatova
2026-12-01 15:45   ` no-reply
2026-12-01 12:10 ` [Devel] [PATCH hci-8.2 v2 15/15] ms/cipso: stop modifying live ip_options_rcu Eva Kurchatova
2026-12-01 15:45   ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201153749.2872789-5-eva.kurchatova@virtuozzo.com \
    --to=eva.kurchatova@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=vladimir.riabchun@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.