From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792674952; b=1hlWmLH5kGwCPEoPqQGS7VER/3KjOGSp8pXapq4Ptm5MW3F/RoHUHcZ34yxdKlezu53B uvlQRKexSxcD+NjvJRaFWJ7OFHaiIaOgF10/LuL6CQMhc9wwMgDWYmQEomordhk0m/CXA EC2UybGEPju30PYSkqfSMU1+TzQk5SLZZ2Dsc2TQkIE7NpKhxOWfPGsqeGAb8rvSwp35j fZ+TrLaA8+UyirVo6WP1G65jw96eIiIZo9pq59Ej9ANqiYA9+h50kBj7POFuNQ1V8crNt KT+ZIkBOUzN7iQujojZbm+mnajTvrDhNL2NuOiDZqpbwyu/roxFzX+nxHLM48PlgZRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792674952; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=TJhxwzQVV2Bitil/P+RgNQfU0rtSwWSbTvYT//HoKb8=; b=PZacwdohBgJUmKjiF/HqtHNbQXOdr/v4dg8jFCtfYv7QcVpsmA/6KuzoyJ6+9uVb4xYo 71gwIUloL84AKP86pICIRmnqklHyCSDyFiByh11958aY2ywG14x+SPttXTuLXcDLS4+g8 5qmvx/Lg7sinmJtpF3kMFC64ofLh9V+EAAsfNcDNEr7i2LltFFNl5SV9GppDsubdwGgrX yT4nX5LleVIr3dcu/KiqOdOjIZsaJDYlNEUjc5tdKSBp6MhYzW4yXoSLbgHdwjcv6jlEV 0QYJYzvAh9zLQ3T4KfWHDe4YkTm4Mu8yTfP9vYkIYF1nnHycOJrR97NCkeqSRHjnTLg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jFvXWqME; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Nx2Qe0Od; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 913DF606A325 for ; Thu, 22 Oct 2026 13:15:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 913DF606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jFvXWqME; dkim=pass (2048-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Nx2Qe0Od DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792674950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TJhxwzQVV2Bitil/P+RgNQfU0rtSwWSbTvYT//HoKb8=; b=jFvXWqMESJTH9w5IZxuR52TAKkGw3ZoR66FVVgje63n/Lbu4OeEOOjNRu8iXfDzuLVkU40 yd2ZvEGzARmzl1Kg0fAL85P85e+e/GJ9NoYPVqU76efC4LB0UuN4YQb9MzyWSswcyWu7cL coGtHQNZHXl24A/zXp7MiXD0QOxcQ8g= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-Vyo9xIDKNNKx7Wpa9ggA4w-1; Thu, 22 Oct 2026 13:15:42 +0000 X-MC-Unique: Vyo9xIDKNNKx7Wpa9ggA4w-1 X-Mimecast-MFC-AGG-ID: Vyo9xIDKNNKx7Wpa9ggA4w_1792674941 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a1fdde384cso11133395e9.3 for ; Thu, 22 Oct 2026 06:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1792674941; x=1793279741; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=TJhxwzQVV2Bitil/P+RgNQfU0rtSwWSbTvYT//HoKb8=; b=Nx2Qe0OdCKTwUZNGToxKUf3/hJLkQv5fRTuI27dc0P/fTuHoDUeZdpW3W8MZHkyozu 7+kfj1XeVDMm6WKlniCdnhAWSHYeLp8GvpphZqxrzaHTxUAuTyRaeyg1NLpohCaLA+cs Qw8RnRBMkB423wG9P63SDN87xBc5NuSUA1CUWbgCFr2TcECvjPIIjr0VAzkUqJXCa7af r2N/KOwg8/Z6T5LB0RNMwTGXxrKL339fAvrIvk14CTwiJhr+fYCDsY64pRuCwhnSghuC jQLC5zl7HTNCPLZdSt7SGFHvqXj2dYVkfFHxLSo6e2N8aDPIkhFcFp4IbzLUU+a7ko4B WL4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792674941; x=1793279741; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=TJhxwzQVV2Bitil/P+RgNQfU0rtSwWSbTvYT//HoKb8=; b=FGwjrhOEPZYMn5biE7ydmcbzgrCfpvPngsBlYc+OgkGfU5+PXFp6p766bpeRF0sGFN hGl1dC/cyE+LSkVZWYUTm86lawYuXhYs5lZ+wvLtlmSBFv2DY3t4ebKPpLqahVSpM8Mq 0Kg3ZB5eG2J/nth5QAvNHrLRHX0TL0Q8o8vcRFt6Mw39AHO8zRFg6O2UBBsl2bGTxm4G 0cGvlY46YcAlhhbH/mwYW7gZ35P8PFVa0EnzCc2p4TJ63HpUM8nGM9Krc40bvZvFfV75 fCWoUUAo86/7A1bpqShYQUquYPbe5t8ASehkdaebx8tEzWw12qHy+gJnfw1rXJQTB0WZ FEOw== X-Forwarded-Encrypted: i=1; AKwUvBwDsvqdqB7qacGJApKBBeBU73KvweyHdkKRE7xTB1qr4F+YzmyzN6QvTVHBur1DkWVV1+wAstlHxdKblqA=@vger.kernel.org X-Gm-Message-State: AFq9FYKo6hzL8bfr0iCOu9Pp+vqiB9vadv50AVKlplnfAaGKyzJh0XU3 5XrL4angaHQWvaq/Hrb3B6VT/pSyLmQ6pYCxcnAhS+e4GGv743qwaVk45Nhflndx+DamlWnX1wo CLbQvtawZdsaDow6DIT1ghkLewxUUUrIYQ8ccxgQILV4VsRJCVjBv9Qqtnx1enJO3GA== X-Gm-Gg: AYBFou2qrZJ3GS8aa/NGFAO5OnPVx/DpBTot0ANvgKpck+cQOIawwZ3gCvJT7jJWW1+ zJbIdzcQ99eAfobS2KOhU1Apz8dr6mkPbTTUFiyvXfjVw5CtXk42xVuC9Q154vM0JtcRfTDmiRL qkwM9JJI2zKXJbDI0rr2EnToytzZsTfatrhMQhaK9fzvgwJUM7XV2hbp48jHojCD5Xpv1lfw0XU eEXFieWeYf8KaSERUpb61sn50rk4EtbJfgjKP6sH7/mY2XRl5DjlS/akkOcpFgmUSMF08dDA1cC zHdnRxwMnnoLa/CBEvmP0a/yZZDIIRb1uhTtarfbemSVZ/5I4CkFW6WP0gG4M7aTPZ8= X-Received: by 2002:a05:600c:34c4:b0:4a2:1a:a10a with SMTP id 5b1f17b1804b1-4a2001aa275mr98637715e9.29.1792674940589; Thu, 22 Oct 2026 06:15:40 -0700 (PDT) X-Received: by 2002:a05:600c:34c4:b0:4a2:1a:a10a with SMTP id 5b1f17b1804b1-4a2001aa275mr98636665e9.29.1792674939765; Thu, 22 Oct 2026 06:15:39 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1536:fc00:b838:383:1c7:6e81]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a203963f3fsm81299735e9.2.2026.10.22.06.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2026 06:15:38 -0700 (PDT) Date: Thu, 22 Oct 2026 09:15:34 -0400 From: "Michael S. Tsirkin" To: =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= Cc: Nick Simpson , Magnus Karlsson , Maciej Fijalkowski , David Ahern , Ido Schimmel , Stanislav Fomichev , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Pablo Neira Ayuso , Florian Westphal , Phil Sutter , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Willem de Bruijn , Jason Xing , Song Yoong Siang , Rusty Russell , Max Krasnyansky , Sridhar Samudrala , Jonathan Corbet , Shuah Khan , Randy Dunlap , netdev@vger.kernel.org, linux-doc@vger.kernel.org, bpf@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net 1/3] xsk: validate checksum offload requests in copy mode Message-ID: <20261022091241-mutt-send-email-mst@kernel.org> References: <20261021180329.26358-1-nick.simo@gmail.com> <20261021180329.26358-2-nick.simo@gmail.com> <87a4o66lio.fsf@all.your.base.are.belong.to.us> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87a4o66lio.fsf@all.your.base.are.belong.to.us> On Thu, Oct 22, 2026 at 01:07:59PM +0200, Björn Töpel wrote: > Nick Simpson writes: > > > In copy mode, XDP_TXMD_FLAGS_CHECKSUM turns the csum_start and > > csum_offset from the TX metadata into a CHECKSUM_PARTIAL skb. > > xsk_skb_metadata() only checks that the checksum fits in the frame, so > > csum_start can point into the Ethernet or IP header. > > > > On a veth, the skb reaches the peer namespace still CHECKSUM_PARTIAL. > > When that namespace forwards IPv6 with nf_defrag_ipv6 loaded, > > nf_ct_frag6_reasm() moves the IPv6 header forward by the 8 bytes of the > > fragment header without adjusting csum_start, the forward hook accepts > > the reassembled packet, and ip6_fragment() then completes the checksum > > with skb_checksum_help(), writing two bytes into the accepted header. > > With csum_start = 22 and csum_offset = 22 on a fragmented IPv6/UDP > > datagram from fd00:1::100, the write lands on source address bytes > > 14-15: an nftables forward rule matching "ip6 saddr fd00:1::100" > > accepted the packet and the fragments sent out carried saddr > > fd00:1::e87. For an unfragmented packet the same write happens at > > egress when the output device does not offload the checksum; with > > csum_start = 14 and csum_offset = 22 the packet left as fd00:1::ebf. A > > csum_start that ends up before the network header (14 to 21 on the > > fragmented path) makes skb_checksum_help() warn instead: > > > > offset (-2) >= skb_headlen() (640) > > WARNING: net/core/dev.c:3647 at skb_checksum_help+0x4c8/0x850 > > Call trace: > > skb_checksum_help > > ip6_fragment > > ip6_finish_output > > ip6_output > > ip6_forward > > ipv6_rcv > > ... > > __dev_direct_xmit > > __xsk_generic_xmit > > xsk_sendmsg > > > > socket(AF_XDP) only requires CAP_NET_RAW in the user namespace that owns > > the network namespace, so the sender can be a container that owns one > > end of the veth. With panic_on_warn, the warning panics the forwarding > > host. > > > > The interface is documented for L4 checksums. Leave CHECKSUM_PARTIAL in > > place only when the request designates the TCP or UDP checksum field of > > an unfragmented IPv4 or IPv6 packet, not IP-in-IP or GRE encapsulated, > > on an Ethernet device, and complete any other request in software, as > > XDP_UMEM_TX_SW_CSUM would, before the frame is handed to the device. > > The frame is dissected from its Ethernet type, as skb->protocol is not > > set for xsk skbs. The pending "net: resolve uncommon partial checksums > > at ingress" applies the same rule to virtio_net_hdr sources. > > > > A request on a frame that is itself an IP fragment is therefore > > completed over that fragment alone, which is also all a device could > > compute, so the reassembled datagram does not carry a valid transport > > checksum. Before, if every fragment carried such a request, the > > reassembled datagram stayed CHECKSUM_PARTIAL and was completed on > > refragmentation; now conntrack marks it invalid. > > > > Skbs without a linear part (IFF_TX_SKB_NO_LINEAR, i.e. virtio_net) are > > left unchanged: their data stays in the umem, where user space can > > still modify it after any check, and they go to the device rather than > > to the local stack. > > > > The problem was found with LLM-assisted code review. > > AI;DR. Ask you agent to be terse, please. Or better read it please. > Also, please do a proper write > down of how to test/reproduce. The slop in the cover is no fun to read. > :-( > > > @@ -1277,6 +1330,11 @@ static int __xsk_generic_xmit(struct sock *sk) > > continue; > > } > > > > + if (unlikely(xsk_skb_resolve_csum(skb))) { > > + xsk_drop_skb(skb); > > + continue; > > + } > > + > > Yes, we need to validate the csum offsets, similar to the virtio-net > work MST is doing. Look what MST is doing in [1]. When that lands, move > the helpers to ip.h as the TODO says, and use for XSK. Yea now this is useful maybe I should add it directly there? Or a patch on top is better after all? The idea of a self-consistent small single patch died on the vine at this point anyway... Willem? Anyway, pls post a patch on top of my series. I sent v5... > > I *think* the IFF_TX_SKB_NO_LINEAR csum_partial scenario is OK, since > we'll end up at a virtio device, but TBH I'm a bit skeptic about the > whole reference to UMEM via an skb case... > > > Björn > > [1] 5de86f1afe1165a1a13ac4ef0615b19f4a10cb7a.1792565282.git.mst@redhat.com