From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796362898; b=XrKNgA1FmIEbrSgh8j0LyJVM3B1pqOFkmv9RhO2kYheqo5A7EOZjCCoaSmPy0s+DnaUK ZwDjZ2rEnWN+tzdTkfe6jVMQK2sjECap5tUuCQppXtTPbeWRw+WJn9AXDE2Gz+MLZScdV IM7dVcXiFjG0j1LWTBcd5n8I3igmkzyrqCvHZDlMyQ4G3f6jZrl13sK0+6fv+j5KKsBLl PcMPAybvl9XMGM3El+k49azizpT87ir+QKLLZXHTUr5yIMD98f34W1NwBmQ3rdG4QsA/X uYvk1XaPK9ZkvcwLP3L7e6GEMqVv8YMcY34oKwuWbifuVICn4DKlSWeQxrrmoBWUIjw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796362898; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:Mime-Version:X-Mailer:Message-ID: Subject:From:To:Cc:Content-Type; bh=mAOTX1O4yQ6TOWdxhrsdP7FpcVYoFYtGolyAQj91iL4=; b=JNVNWoqwHjfvSPugTsP55fIymoFFXZkgii3Mxx+hqu44hawZybFD10JiJezQGeZc1nWq x0EUA0Hh9cfaIPl9vBAWdDHxwF60agu4qEreGfbyAVrhY7ytKHf3fdO7mGlV4rpIg7sLA 3REjFe7Si/tjy2mwzgRI0538Xflmbqbj70IRtnAR5925JMHU2cTjrzHk3NLCQBlw23vvw F58O5E0bDypZDxNjTBObzji5fhPtFltnLhjMJ3v6W8kfN2f3+aLp5WSzL+FaBl63Nm1w8 dBc3fT9lMjsrK1xKsilebm/oFPufkmri9t76RroVxrhdesy//+gvlgqgdVDHYfA0/SA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=dkQne7dv; arc=none smtp.remote-ip=209.85.210.198 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (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 A6EEB606A693 for ; Fri, 4 Dec 2026 05:41:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A6EEB606A693 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=dkQne7dv Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-8a0688a43d3so425612b3a.0 for ; Thu, 03 Dec 2026 21:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796362896; x=1796967696; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=mAOTX1O4yQ6TOWdxhrsdP7FpcVYoFYtGolyAQj91iL4=; b=dkQne7dvs7DsAYDkLgHH/tJuLB4KhR0SF8Hz7ZArf9f7IN/WttRIX3JaRmTViqZXZT wtPt3rwh4epkNMHMhmr2vxI/6pdsl0SHCLOQOIHAlS6vopexPwlAKYWjIorGlLOWfD5z kJOmUB8oQb1hjzifd9EE5Gxe16KE2fUZqO+RxUmKIrswRSPwZPtjklYcgIetVBV/pDa8 3/vc6GtyUxuM+dbh6DI1bZKabyMua3cHldpqVux1KIfyPp+OwRnLyTcHcmEVmBVmVwo6 pNmsgcgWwt1oLTuQ5rvFMST9n63L0/DbgHKDJCS5kV9obZfCQ+PdxA9SxmOO9kdv9SE4 hnzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796362896; x=1796967696; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mAOTX1O4yQ6TOWdxhrsdP7FpcVYoFYtGolyAQj91iL4=; b=mHxuRCBPeQFzAjRfvttqb/QUCKtvGDv+oo4/9Vs6CQNvG4+rFcWLtCHJqLJT07yRuB ZLjEGPtYfB66weIoYxSWShd6G8MRY2S8r7a3U9olge+4dpOwPQDNBGmys+IxAPZXAGpA v6FfhT0jOCsrd6L5oIMK9I5qv4wOv2tctK1uH+auDN1jBXqG+jkKF+azmJiTSdsrJRlA E87yw1NwoFLXEOMwHcx4lBCuQYxchv3Qrc/73ddV/Z4gQ1O7PJaDSWmUDRwT988DsnnQ VfDywkjkqDNgvUGF1iikl6QB3vPU6iqaFV7MYRMrnjP+0WnelDhxKW15l/xtgRvfuW32 xe9A== X-Gm-Message-State: APuU4Z/Idystzj1w8tbrnwaXxcPKeniE6QZd9X1q3ueA47Yc6CjlIQdw 5iStKzFmerg82Nx7Do647X7jelmcPyqyeVt5nyBXkAaDSIMOlHqFXV/PDIlUFPFvhdx/kDKDddn HA58rDu/eZtfJyzHdZpv8PaGUYPD4E6m01RM2PJ9l7i/NW0G7a/w29bbaFDj4jeOIW6T0T26Ex8 z5aQDr+OEvq3GUTthRN7RGoxU8OWvxUvs= X-Received: from pfhc6.prod.google.com ([2002:a05:6a00:cbc6:b0:8a5:89dd:316]) (user=tavip job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:230a:b0:8dd:b37a:6e8 with SMTP id d2e1a72fcca58-8de2a799e85mr1123597b3a.3.1796362895766; Thu, 03 Dec 2026 21:41:35 -0800 (PST) Date: Fri, 4 Dec 2026 05:41:04 +0000 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204054107.96092-1-tavip@google.com> Subject: [PATCH net 0/3] tcp: fix zerocopy leftover copy and mid-frag recv_skip_hint From: Octavian Purdila To: netdev@vger.kernel.org, Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Willem de Bruijn Cc: Neal Cardwell , Kuniyuki Iwashima , Simon Horman , Arjun Roy , Soheil Hassas Yeganeh , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Octavian Purdila Content-Type: text/plain; charset="UTF-8" When TCP receive zerocopy is used with copybuf enabled on skbs larger than the caller's mapping buffer (such as GRO, coalesced, or BIG TCP skbs), two bugs in tcp_zerocopy_receive() cause sustained fallback from zerocopy to copying: 1. After the mapping loop fills zc->length while >= PAGE_SIZE bytes remain in the current skb, tcp_zc_handle_leftover() still runs using zc->recv_skip_hint (the remaining skb length) and copies copybuf_len bytes out of the next mappable page, misaligning copied_seq mid-frag. 2. When copied_seq is mid-frag (offset_frag != 0), tcp_zerocopy_receive() breaks with zc->recv_skip_hint left as skb->len - offset instead of computing the exact bytes to the next mappable frag, forcing callers or copybuf to copy the remainder of the skb instead of realigning at the next page boundary. Patch 1 skips tcp_zc_handle_leftover() when length == zc->length and at least PAGE_SIZE bytes remain in the skb, preserving sub-page tail straggler copying. Patch 2 calls tcp_zerocopy_set_hint_for_skb() when offset_frag is non-zero. Patch 3 adds a kselftest covering both fixes and sub-page tail straggler copying for IPv4 and IPv6. Octavian Purdila (3): tcp: avoid spurious leftover copy in tcp_zerocopy_receive() tcp: set exact recv_skip_hint on mid-frag in tcp_zerocopy_receive() selftests: net: add TCP_ZEROCOPY_RECEIVE leftover and hint tests net/ipv4/tcp.c | 9 +- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 1 + .../selftests/net/tcp_zerocopy_receive.c | 428 ++++++++++++++++++ 4 files changed, 437 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/net/tcp_zerocopy_receive.c base-commit: 90ae4042bd9f35a9098d14b1a12a43df9b326e2b -- 2.56.1.915.g69d5ec7298-goog