🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7028

[PATCH bpf 0/3] bpf: Fix overlapping copies in xdp and dynptr helpers

#7028
From: Ayushman Rout
Date: Sat, 24 Oct 2026 09:26
41 lines
12554 bytes
My patch "bpf: Use memmove() to load bytes from an skb and an xdp_buff"
was applied as b93cf2c8a055. The AI review on it noted that the
multi-frag path of bpf_xdp_copy_buf() still copies forward with
memcpy() and breaks when the buffer is a slice of the same packet. This
series fixes that.

Commit ab08863c58b1 ("bpf: Use memmove() to store bytes in an xdp_buff") fixed the
single-segment store path and left the cross-fragment case open. Patch 1
fixes that case for both load and store.

Patch 1 fixes bpf_xdp_copy_buf().
Patch 2 fixes bpf_dynptr_copy(), which has the same problem when both
ranges overlap in one packet and cross a segment boundary.
Patch 3 adds selftests.

Testing: x86_64 QEMU VM, ./test_progs -t dynptr. With the fixes all
four new tests pass. Without them the three xdp tests fail and the skb
test passes.

I also read the other memcpy() calls that could touch packet memory.
I found no overlap path, but this is not proven, so I left them
unchanged: the sock_ops header option copies, bpf_file_fetch_bytes(),
bpf_flow_dissector_load_bytes() and bpf_lwt_seg6_store_bytes().

v2 of the earlier patch:
https://patch.msgid.link/20261022112312.31563-1-ayushmanrout27@gmail.com

Ayushman Rout (3):
  bpf: Fix bpf_xdp_copy_buf() when the buffer overlaps the packet
  bpf: Fix bpf_dynptr_copy() for overlapping ranges in one packet
  selftests/bpf: Test overlapping dynptr copies on xdp frags

 kernel/bpf/helpers.c                          |   7 +-
 net/core/filter.c                             |  59 ++++----
 .../testing/selftests/bpf/prog_tests/dynptr.c |   4 +
 .../selftests/bpf/progs/dynptr_success.c      | 128 ++++++++++++++++++
 4 files changed, 172 insertions(+), 26 deletions(-)

-- 
2.54.0
Technical Details
Message-ID: <20261024092659.76422-1-ayushmanrout27@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-351346-linux-kernel-netdev=dewy.ru

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-351346-linux-kernel-netdev=dewy.ru
From: ayushmanrout27@gmail.com (Ayushman Rout)
Newsgroups: linux.kernel.netdev
Subject: [PATCH bpf 0/3] bpf: Fix overlapping copies in xdp and dynptr helpers
Date: Sat, 24 Oct 2026 14:56:55 +0530
Organization: Usenet Network
Message-ID: <20261024092659.76422-1-ayushmanrout27@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="731765"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:EzXkv5epQ73wKzuDwzyRB3ynyhQ= sha256:l/cfqIE0IihXuxuP2adGWP2Qo6XnKiOEQJoiMfVNztg=
	sha1:1tPZ5LIvDxJEryBS6lLfap35Js0= sha256:02LbPb/o5aSzn90E5J8DeP1BZWdkZooef0j6aTOmRvo=
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 8534711161C; Sat, 24 Oct 2026 12:40:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.047
X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
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 r3Dqxo0Qcd4O;
	Sat, 24 Oct 2026 12:40:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351346-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 6F12211161A; Sat, 24 Oct 2026 12:40:21 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 51B78611AC; Sat, 24 Oct 2026 09:28:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792834084;
	b=aPmDvqIYU0Wk9a4EVDN4eRkqWqvQJq6kRiHkPeW3+oq5tDGUlvAHohntTTYaCHlKZo1D
	 YUiirpR2sQOaQC0BJu6LwHJAWfAh58OkekFiozsCxvpP7bfhJkwqeMvKcWUiJ4BMPl+fG
	 N+qNvpaw6aJSRww38lQCToeyUZxK9N6qiPuFp6I82cYfy0kmqu8vwYiVRysXwEJXjAwWQ
	 E5Kb56FlyMBsMAJlca//FyGbao170CRKdHhgrfvZ4GewvGewNe/tlNvjHPzJI1dG2o5jF
	 EQGUkYaru511b5BvmkPKZ3x8HOqgbl/PhkUiaUuyhQLwdLuC6VSHNXfBe6gDFO7pvzA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792834084;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=j2rRh4N7cmK15/HNyDskN6MSE+BR1CVHfRqKHHQTGoM=;
	b=xokp6XL3C774s5Zkh5cvsRdBV96FLH2sercB2vu9nPCrwlQ9ZrIHb0LIW9NKOFmAYSX7
	 e+Zp/aUQRt1N8qddH7+GTsIZ5GivgopCphJDlgH+DtI3E0t2Jhe2VDwBdbwVG0OK+ZV7z
	 +Y1R85dDJnUa/5qGEOfOMvsNReuVAG+UWGIta2jOz+Hp3+WfbmLB/hXfcjD2YMHReunKl
	 uL9Lf4lX/ikoro17Crhgtkg3RSlnNERCFNw1zAOvxENBx526MaE5Bz4ykYZ7ekPW4T7Fo
	 f/h3X8dusKu+XSrYzFp9/KOTqlEDiIZc6UvkQThilb/klLDuGKsi7wlUA0UhTFqKGkw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=kt5wAM30;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ED48606A326;
	Sat, 24 Oct 2026 09:28:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=kt5wAM30
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.181
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792834083;
	b=vllIcXvMp9uWlqrOBa3kjNla9wFP4KUnHJ88r8ILn+MUjL8Ok6zuHvNLI6ydLZ8Yqba4
	 8acecUkiWFLh6tbTB2rDwSJaZQ6cW0e7D5E5T1qUkqcQh8J0wLWY6pkFF7xYyrL4sSZ1J
	 m8A3pkvTTLlHRWC//9yONvIr6+rUmN0AjAl2kMjebuLbelqQqm5v3j1e9bggEVEQs/ARt
	 ECr1A/X6Um6JvuAdBfd9hIKZTLS/xvhzcPDsQ4lsv9aP5iJeN+A/O98GU6A2z+M9FdI2s
	 BBrefEahjWQynI1C+23ySSTzRVF+SUpmWBz1gJQGL/SmUgqkZ1TQsgfZofEKpQGYvsA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792834083;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=j2rRh4N7cmK15/HNyDskN6MSE+BR1CVHfRqKHHQTGoM=;
	b=0D58JdwiqCywpTN8V2ab+AerOcX3Oe1AvZinMNsX3qOkcRcitC5GeQT/6Sgy8N/Yedhf
	 S3Jk0EZh42qks6mIng4Jo1tsmqbvjC2Yz7ER9uh5teWZcZY9ntdH1V5v5kwHVz1kt/zK3
	 Llsvag/cvk/yA8ByfEr1S0EboCtjk3pCSZ2GbxUi0N2TOWIoz3sw0rmajIRiYz2DK/H+x
	 5F8RMuXKwyyGT+gUgrEEr9bBX6hAL5jLmwIxPLYY4RYkybboCgHKHgrH0Qo1KvkZQZQqF
	 XP4akhn6fxSHZAoaNvA+HECzI9rTQ9tJcxtpxzRLSsn6i1XFZzfJJRbi0DQgtWqAcSQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=kt5wAM30;
	arc=none smtp.remote-ip=74.125.82.181
X-Received: from mail-dy1-f181.google.com (mail-dy1-f181.google.com [74.125.82.181])
	(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 051C5606A31A
	for <netdev@vger.kernel.org>; Sat, 24 Oct 2026 09:28:02 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 051C5606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f181.google.com with SMTP id 5a478bee46e88-35b2c599f43so135331eec.0
        for <netdev@vger.kernel.org>; Sat, 24 Oct 2026 02:28:02 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792834082; x=1793438882; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=j2rRh4N7cmK15/HNyDskN6MSE+BR1CVHfRqKHHQTGoM=;
        b=kt5wAM30en/eWwJ1xUWn1Q/+F9+W7xlIlkhPgwU8OW5vlcB+owd3ZNxVpig1TyYmrZ
         ODPxWvq77miY1Iw6X+fO8iZGu4ZaaRXIK+zq+xeqtYH3rQUCxQ6AqK6fOpJlAvb+Y7LH
         1IEfS25eMQ7xbwpurUIzgfgt8dYHEkilZSZ/y0KA5j3gfCsIChSX+TiCcCYZqp5Y3/td
         jVfE54k5ESPQ8jc6EW/P+Pqn91rbr97YG6BTJ2lbVxdtD1xvVUM0FZqckeM+MSZrb4zx
         UX5JtCLe09jvNpO29EikD+QGahnSji3o0o8F3Wyi7lFuECHa/4QjGTzvDxzgxK7PR84c
         WZ0Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792834082; x=1793438882;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=j2rRh4N7cmK15/HNyDskN6MSE+BR1CVHfRqKHHQTGoM=;
        b=0B4RUuQvYHEWp3YiwzjsxrxrFAzSdH0IuNes5wz+S2ynStWx2Auv1J3YY2MdhqXmhe
         CV5vrzyHVINbXQPOjpcv1+BF15RIexdugfcU2rKjftbPLYnbdHtumRg72pURpRs8nhR6
         x6bzhs3ziCESYPsnuhMvRhBsINeeC0Eyn9Mk3fvNMGwlMpzTOvo8fvkKa9XGz10iMG/n
         TYGKbOYogaxnFXfWIkGLB8jdKzFzBXFLM8oxiosBjsGbKpXoxXXwvw09zjnqpwQVj4OO
         ysdKmZ6fyQ0CbecDUgG62RRLd0Z97bNDtVwNsURr7WITkpxCePQpiL9TTJGnPkGAbaRp
         USGg==
X-Forwarded-Encrypted: i=1; AKwUvBxzf4ClSe9OksPY4tSeVluXhqm/9Nq3T5qXgrhOIYdNqRCAXDStqh2cu3aSMop9L3VYpPZAKvg=@vger.kernel.org
X-Gm-Message-State: AFq9FYJplIYogcEzqGUS0qNL23F8KMsk6o11CCpo5sP3meEVmsoAIUex
	/n9Bo2gBUrl0fQK9Kt9Day7m3/pEc5byZVPZsosol8G0IcMY86CI27aY
X-Gm-Gg: AYBFou1vRWq9IZaDJkf06Skue+3wZYVqSWpLFM7mOIE7rtx880tURTfPsD7ChSBoirw
	M9D4ClARMn7X11VAcLD1AYVX2yH43qZNbhMSfZrP1Dcl+iWKMeU1EoaKRgfF/IuLGZrUPhbA2aP
	0kGxSB4vJzRQF6hEfU43xWViYQ/Q2WUc25zuSNx6v7JCJMj+DlTPioh7I+kc4Vd9XjjIObtJpcx
	EaTEV9A8iDTzVcxLtwqK2kprZgH7gqUR/z9uoR0cSxwsg+DBrWj1H9lcRy27OpltaKDG9dkHheo
	sDI0q+zUlUaoPZWpqFPsWtvR1EZR5oJqr7DVn6yv5pELc3gKtcv1p5QWuKtOt//vcK1DvUMTZx4
	3TpiSHPoa+X812i3MaDy3fveVY+lzoPtOjYWt5geOEVMcR8Aa1pqbWNh/4M3770YkRTYu8yEV2T
	NI6NG9L/EmdfISh4bzqfuvV173M5GqJSnU/6WgWaMw8SC3D+jKGhS/R9URHZ12rIhTjTiu4zpLQ
	Rqe9Q88QBbnUrDZf3D/EOVygJxSr/ouJXLKlqkGoD2cd189Cn4yjiBiWcegelcN2ckOctFFHTO7
	gFBpEVDF9wKkD7duE0MOLhFb4MTZOFF+FoMrMsoH6f8ErthXec/wcWR8LTYwbEPW6Kb6kIJnyA=
	=
X-Received: by 2002:a05:693c:415a:10b0:35a:7020:c08a with SMTP id 5a478bee46e88-369e846b175mr2885481eec.19.1792834082019;
        Sat, 24 Oct 2026 02:28:02 -0700 (PDT)
X-Received: from nixos ([2405:201:c40d:9039:e1f8:b9bb:b037:3cab])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369e8daf444sm5236604eec.18.2026.10.24.02.27.57
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sat, 24 Oct 2026 02:28:01 -0700 (PDT)
X-Cc: ast@kernel.org,
	Ayushman Rout <ayushmanrout27@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	netdev@vger.kernel.org
X-Mailer: git-send-email 2.54.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list