[PATCH net] calipso: update payload_len when removing the CALIPSO option
Joas Antonio dos Santos
joasantonio108 at gmail.com
Wed Oct 7 15:25:00 UTC 2026
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 at gmail.com>
Assisted-by: Claude:claude-opus-5-5
---
Found by code review. Compile-tested only (arm64, W=1); not runtime-tested.
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);
}
return 0;
More information about the Linux-security-module-archive
mailing list