Article View: linux.kernel.netdev
Article #5971Re: [PATCH bpf-next] bpf: Use memmove() to load bytes from an skb and an xdp_buff
From: bot+bpf-ci
Date: Wed, 21 Oct 2026 11:04
Date: Wed, 21 Oct 2026 11:04
67 lines
10038 bytes
10038 bytes
--===============1776289824786463327==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
> bpf: Use memmove() to load bytes from an skb and an xdp_buff
TL;DR: bpf_skb_load_bytes_relative() still uses memcpy() and may corrupt data
when its destination is an overlapping dynptr slice; should it get the same
memmove() change, or should the commit message explain why not?
> diff --git a/net/core/filter.c b/net/core/filter.c
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -1789,7 +1789,7 @@ BPF_CALL_4(bpf_skb_load_bytes, const struct sk_buff *, skb, u32, offset,
> if (unlikely(!ptr))
> goto err_clear;
> if (ptr != to)
> - memcpy(to, ptr, len);
> + memmove(to, ptr, len);
>
> return 0;
> err_clear:
Should bpf_skb_load_bytes_relative() get the same change?
It has the same pattern and still uses memcpy():
net/core/filter.c:bpf_skb_load_bytes_relative() {
...
ptr = start + offset;
if (likely(ptr + len <= end)) {
memcpy(to, ptr, len);
return 0;
}
...
}
Its proto declares .arg3_type = ARG_PTR_TO_UNINIT_MEM, the same arg type as
bpf_skb_load_bytes() uses for 'to', so the verifier should also accept a
slice returned by bpf_dynptr_slice_rdwr() as the destination there. The
helper is available to tc programs through tc_cls_act_func_proto() and to
sk_filter programs.
Since ptr is only checked against skb_tail_pointer(), the source can overlap
a rdwr slice taken from the linear area. For example, in a tc program:
p = bpf_dynptr_slice_rdwr(&ptr, 8, NULL, 64);
bpf_skb_load_bytes_relative(skb, 0, p, 64, BPF_HDR_START_NET);
This takes the memcpy() path with dst = src + 8, which on x86 with FSRM
would repeat the first 8 bytes, the same corruption the commit message
describes for bpf_dynptr_read().
The Fixes: tag and the subject ("load bytes from an skb") would seem to
cover this helper as well. If it is left out on purpose, could the commit
message say so?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/39587398602
--===============1776289824786463327==--
Technical Details
Message-ID:
<5a586e05ad8d24d79759c1d99d6d58eb661dc6f4a4c8d258e05a4962cfe7e59e@mail.kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349968-linux-kernel-netdev=dewy.ruReferences:
<20261021103957.17532-1-ayushmanrout27@gmail.com>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-349968-linux-kernel-netdev=dewy.ru From: bot+bpf-ci@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf-next] bpf: Use memmove() to load bytes from an skb and an xdp_buff Date: Wed, 21 Oct 2026 11:04:26 +0000 (UTC) Organization: Usenet Network Message-ID: <5a586e05ad8d24d79759c1d99d6d58eb661dc6f4a4c8d258e05a4962cfe7e59e@mail.kernel.org> References: <20261021103957.17532-1-ayushmanrout27@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1776289824786463327==" Injection-Info: usenet.network; logging-data="4118312"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:xM5lf+wddV4/lKd2IBAsl+2XUeY= sha256:dtT4+OpqsWVPVDVx9sZSxIVo5u4dUoUxH7NLWopDzGk= sha1:tSdwsgoMSvYKyxLEnfOyGjuH21U= sha256:ty/IgJ3cz2Y29F2uzlto+PnVDtl7l/U9w7deCnmb9UE= 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 15D3E110FDA; Wed, 21 Oct 2026 14:10:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 PBq6OLNq45kt; Wed, 21 Oct 2026 14:10:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-349968-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 02BD5110FA2; Wed, 21 Oct 2026 14:10:42 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 867972C7E0; Wed, 21 Oct 2026 11:04:32 +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=1792580670; b=skhBcBrbfpzDTzjmE8ekuQyn6M819H+yqMVQ698rjRMct/Bf8x0rAfrGclcsMOYaf/ad LGXf2UWovQtkfu6caJcm+2ddTQAGZV0dU+4CeUkcJUwbL6D7Fg1Gl0Zc+ZoIdKk2EA7uf 9S4QRObAFs+YCyYEOLg31mQwuoYpoe2hKsITyFPDItd6D7xYpYZREi0u6PUUptkpeUUwN 6QztD7+FXWMJ+NglKBoS72iyg74YLigb23Zp7r15ete1AzYhNskrWIMZYRmK0yqDH75Ez qRIFNUW+f7uTZ0gP1HPKGHZ3oCmsBm5uHRODUF3cEeym3JNcLZYbaTePc2HMBUKvQ1w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792580670; h=X-Original-To:Received:Received:DKIM-Signature:Content-Type: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=757j6HC9/ZJcr0KvzkZU6AFyWK11pyb92mCjzCpfo6Y=; b=3Y2O9x7KZoyuGzhZFL7bO9DWp5H6aXJW2840glFQkIoPoRDoHiCT+Vg/lKQmTZPhmG65 j0Ai85UgoN1FrCOWToxIg6hXS9Wqbkbs1UNwh8MBv7YzW6qZ2l7JdQZStJC8Kx9G2tw+s 7MZqbwvI2sathJJiu/i3hzAG8ZpszYCGS/g1LRSlXYG6DqqaxR6f7p25NpF9v7sElx+o7 XgFD9pYYRNQ75e0KJH9SDNwuLsTABMl88J63iMk87d38BbacvDAuWt2hQ+RFPN1syhU1e J68gbMwkdnohy5VLTEJj0oH2OZd7bZk4ZiMGlMviS+C7QhbtdjWZJtgZrbjHIiBSDOg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqeHBMbu; 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 01E4D606A321; Wed, 21 Oct 2026 11:04:30 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqeHBMbu X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792580667; b=Q+X2NJ/CeojwrNbyRdfqGVnD58Wvx9NeRR+xKZUA//MX5D/wuBPwjsMMVw8iadFXkxTT C6RgMjzZygu9D0orVZZ+zg8Isx5TnXcX5Hi/l8ZdXVQ4nZhrDu6xwxj3uvFYyR8ekP/RN xT1eynzJB37ElmY4Ww8rXFSdWsOirXeJm9Vpzuj7pDycuwbvXar48lnOcxnR47X2gWNMH w2C2gRPz4NvzK07Q6FJz8eYT+/0heiu7GgmDmdV5b6pH1d7vNP2S5N/pX200tBfwXdp6g wiA0rtQTpvoGLeclvW+Zz+uo6Qbg73knJh7y+O5uQuZ5iembaVYApmdkxXRUQFH9KwQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792580667; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=757j6HC9/ZJcr0KvzkZU6AFyWK11pyb92mCjzCpfo6Y=; b=YPFOaMhXEv0gnh1cEJhx3/eo+AZLKA5sBlSqYg/h0yEWPlWZG2vYhnbiClx1xjE5XwhE qany3tTrNueskjUsdQfasKwCcNO5qCImLXxxadqSNOWicObytzZGhmuC93Kpx6GTzJrNy xTYzgA7pidSAVKl84O02ZMTKAwzO0QKZBOzlPwynjXKhSCpUWJLdY/9C04MbKe9Spo1cd 9HbzlKuloISTumm4cBX5V/iFvsV+HEjKgIeKcm7/qbMpdwwaAJ978uEyVx11Gy3IxauP/ yslGIeDgN+Cm05BRDfldCcLb3TmAn9tlLw38dAI2UPTf7NV2ZgH0kA2S+nfR1S3nkLg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZqeHBMbu; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 198A6606A319; Wed, 21 Oct 2026 11:04:26 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6070F1F000C9; Wed, 21 Oct 2026 11:04:26 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792580666; bh=757j6HC9/ZJcr0KvzkZU6AFyWK11pyb92mCjzCpfo6Y=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=ZqeHBMbuj5HPn0jHjN8UcyVsdpArJ9Ux1/1JVpKTayRxx1TuNkn7xXuC7OaE4YB6p et3ByO0EdjxPImpbDNTZISmmL6OvcuyHKQtF85Nod65YO5RF0B1gtwaeq7+Emiw2Kr 5pq5UKziYxfe97yzXpZk18t/1MRc4uyhHh+DLzsWfaNeSR7WcY6WgQaoHqour6gW+z CYE4UZQK1TLrr/6ES0mfUExvDBIACPJLwyXWqQCBYGAywkzYfS5ip8Uq1kV3Jyh1EB L+mzOynzyLspsQiG+MIt/fweOzxsh6TisBWlbRX/xDt5Y6HkO4UjA7wYjWR0/HqMEs HvJEnXWKBJMAw== 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 X-In-Reply-To: <20261021103957.17532-1-ayushmanrout27@gmail.com> X-Cc: ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,memxor@gmail.com,hawk@kernel.org,drosen@google.com,netdev@vger.kernel.org,ayushmanrout27@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev