Article View: linux.kernel.netdev
Article #22728Re: [PATCH net-next 2/6] net: remove header_ops->validate and dev_validate_header()
From: netdev-bot+sashiko
Date: Wed, 25 Nov 2026 20:06
Date: Wed, 25 Nov 2026 20:06
113 lines
12288 bytes
12288 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0 (1)
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In packet_sendmsg_spkt() (net/packet/af_packet.c), the
SOCK_PACKET send path now checks the packet length against the wrong…
Pre-existing issues:
- [Low] Baseline decision: false (kept only because
requires_validation=true).
--
net: remove header_ops->validate and dev_validate_header()
This patch removes header_ops->validate and dev_validate_header(). Their
only user, AX.25, has been removed, and so has the CAP_SYS_RAWIO bypass.
The three af_packet callers now compare directly against the snapshotted
hard_header_len.
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 96c5216a9d6b4..230b16742346c 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -2060,7 +2060,7 @@ static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg,
> goto retry;
> }
>
> - if (!dev_validate_header(dev, skb->data, len) || !skb->len) {
> + if (len < hard_header_len || !skb->len) {
[Severity: Medium]
Is this check still the same as the old one when the lookup after the retry
returns a different net_device?
packet_sendmsg_spkt() looks up the device by name twice: once before the
skb is allocated, and again after goto retry. hard_header_len is only
read on the first pass:
/* Keep the allocation-time header length across retry. */
if (!skb)
hard_header_len = READ_ONCE(dev->hard_header_len);
The old dev_validate_header(dev, skb->data, len) read dev->hard_header_len
from the device found on the retry. That is the device passed to
dev_queue_xmit(). The new check uses the value from the first device.
Between the two lookups the RCU lock is dropped, and the code sleeps in
sock_wmalloc() and memcpy_from_msg(). User space can stall that copy with
a userfaultfd or FUSE backed buffer. Meanwhile the name can move to
another device: netif_change_name() allows renames while the device is
IFF_UP, the device can be deleted and recreated, or the name can become an
altname on another device.
Take a name that first resolves to a tun device (hard_header_len 0) and
then to a veth device (hard_header_len 14). A 1 byte frame now passes
len < hard_header_len, where the old code returned -EINVAL. Can that frame
then reach dev_queue_xmit() on the veth? If so, eth_type_trans() on the
peer would read eth->h_proto from skb->data past skb->len.
CAP_NET_RAW in a network namespace the user owns is enough to reach this.
packet_snd() and tpacket_fill_skb() have a weaker version of this. They
no longer see hard_header_len grow on the same device (for example
through a bonding type change) during the sleeping allocation and copy.
tpacket_fill_skb() also uses a single value for the whole tpacket_snd()
batch. In those two paths the old live check could also go stale right
after it ran.
The commit message describes these as "direct checks against the already
snapshotted hard_header_len". For packet_sendmsg_spkt(), though, the
snapshot comes from a device that may not be the one sent on.
Later in the series, "packet: validate TX header length before skb
allocation" moves this check into the first-pass if (!skb) block. If I
read it right, the device found on the retry is still never checked at the
end of the series.
[Severity: Low]
This is a pre-existing issue, but with this check the short-header branch
in the allocation path of packet_sendmsg_spkt() looks like dead code:
if (hhlen) {
skb->data -= hhlen;
skb->tail -= hhlen;
if (len < hhlen)
skb_reset_network_header(skb);
}
hhlen is either 0 or hard_header_len. Any skb that takes the len < hhlen
branch is therefore rejected by the len < hard_header_len check after the
retry. The branch already had no effect on sent packets once AX.25 was
removed.
"packet: validate TX header length before skb allocation" removes it later
in the series.
> err = -EINVAL;
> goto out_unlock;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124170551.1874487-1-willemdebruijn.kernel%40gmail.com
Technical Details
Message-ID:
<179563717146.3135.13828888789756005056@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371651-linux-kernel-netdev=dewy.ruReferences:
<20261124170551.1874487-3-willemdebruijn.kernel@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371651-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 2/6] net: remove header_ops->validate and dev_validate_header() Date: Wed, 25 Nov 2026 20:06:11 +0000 Organization: Usenet Network Message-ID: <179563717146.3135.13828888789756005056@kernel.org> References: <20261124170551.1874487-3-willemdebruijn.kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="291976"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:pytkt7nPN5fSr+ukK8EKK0JbU5w= sha256:ACOcOwBc95DxKIYkOznwfH8VuTrNWptTMpNiTCrvn6g= sha1:FwcK4sxwEYmm1t9coYrJJPjfLpg= sha256:44nuXJmjOejDgg8lRkGHIzRl4uyeaWSaMOLVGlYSNR4= 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 A246E125E9E; Wed, 25 Nov 2026 23:06:30 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[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, URIBL_BLOCKED=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 faFIBCFXXVPK; Wed, 25 Nov 2026 23:06:27 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-371651-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id DE475125E94; Wed, 25 Nov 2026 23:06:16 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 1D2396051AA; Wed, 25 Nov 2026 20:06:16 +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=1795637173; b=fZmOuVRvYJpnZ9Bg0ENNmU4j28l2Fr92lhOkPCd/oF0Nclgtb7ueUcLJUpPehi+Mg1tz Q3Xk/I337y33j98aj9cNMIbS3Tyk9w94hrZpPkzW6H+K4R/7UJuPpi9fCFDgRqJeSjDxG TzdWh6dHTetBhkmSOnMkxCG45IwKT8D3cy1L5xXxg2SWxUjIBrGquMIcISyfV1D9zDv9t 3huiv/GYbgDaB6eivjelvVyMLySB6vxRs0QU7Kf6dHMXRqV9eDGNOwi/1biZ5i650EREx NHnuAhCiH5gPtba+V8iM1AF36MFEuTOx75KntP69sMJa1xgcnhWb1zb9LAIZF5/u9tw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795637173; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=paAhnZ1B00/VYOGiEJQJittNIUN4WOaYQBUyWbu46us=; b=ibtivEVRncFlljCA6F0rsFTliHZGH+1Dr2bDvgcqaY6TbpQgHEC0vYCAtkTTLojqDgmW fJNF910lb7T2NBK0U8QRShFpKexx7oF8MxbzTiJVZuME7b8fztyB3DKDK5Ym/IRuYDr6F p7BCf4E3b2ic9YSnPz0GAf3+HIHH/2ciwH2PCC0eDxzmgMLIT2zWUesFk6bFkSWTc1bk6 nWgo4EIppStmYMQMPSyVMfsK9LV04LArVzknF0SM+Vhcz/Ytrx493ZJ2caSPVImjTuhKw 3Ax3Y8b5yO2PWpyBYlCt5oXwT796JEa/ARz14HH3LB5wfp575fvGLhPU2E06RyS+8Nw== 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=Hgy6ip4g; 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 BBA71606A32A; Wed, 25 Nov 2026 20:06:13 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hgy6ip4g 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=1795637172; b=1e/Zc6ZSAHcUnn0edvydvPuB4vxw+khSb1Qdt16NHFvxL4H+47fxymRfVCMC1TlBq19z DKfTuQgMIdMVQ4rIg+W90kARHuVBZ+/qBWXljWYzxfiqMTB9fasbQGvKgRDS2nmL4AahN LX/xtGU33ZLYCsTSak8ooGQHcVSfB6yTKUl2GMjhS8N8VXFOXbA1tBW3mA+k64uJwV7gc Qu0OQsdEMi77vc3PfHn2lc9Pe70Tpt3t4doAOifg4uw/Zi/bTnlY+PhA7GSvKgrjYW72G tsSY9mMcuLSbCS3FvZimGPUk44BKpwyjPCZ0ZKU6/wvaq7If5htQueGLknyU4LisekQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795637172; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=paAhnZ1B00/VYOGiEJQJittNIUN4WOaYQBUyWbu46us=; b=N8BlPUDJfDYgWyiZ870pU1WEUHvcSWcDQIFt4m7cuLUBz5H6wcvv7g9qcstMJ0veqJxY U4uAwQBTiQyL/FWXTtwLdeaz7VWMWbcHYx8bvBq/Lps8Clr0XtPoJ+bVO40ZhtVc7iaKb 0yJeulP3vdnJ5NrvzOnN6me1SgsHciagC8ommsFtVtgVrFtOaVJYVEnkZq5V0yv/iTFhI Tnk+SAQsHCJxuJsw77Qs1fxBBgG6YA++6H9Vnl1XCN/8XzYcfODU22Gpp6hBe9prng2tO qeaui/sRUZYnAl971eKGIbWcPm+3ELKJGZ3JC8Di8jzzAnWdIQQiHHfS3DKD5rQU1YQ== 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=Hgy6ip4g; 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 D799A606A321 for <netdev@vger.kernel.org>; Wed, 25 Nov 2026 20:06:12 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E48201F000C6; Wed, 25 Nov 2026 20:06:11 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795637172; bh=paAhnZ1B00/VYOGiEJQJittNIUN4WOaYQBUyWbu46us=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Hgy6ip4gtaD/u7rSg6A9itabA8uCxHujIrJxViXM6LLSZLAcMSgCZxqz+ZuQknUrG vw+0EyVC/IybSvgtSeMPq1rrI+INgJHj5FH7jtuNZxOhCP+WNN6pkq+HYH2qOz4URN RkH95v8IBt5ZAJyej7pksJ+93MYcpJup+8qUYD90yeeScR3Q2eYZdjU6jx/aIWRJic b8rIglp+1OmH/fPGJdeMGlc0PvHRw+C1aUaiOsbzIY69HRwAWcKvD5P7ttgCNmik6F 33bXZFNPVQN34nlZzI3sKNrBl+ThHtd/WwvcfQaPNMN7bawFvtgQLpEmYjayqtn9Pm Q918PPyBa1ang== X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, elder@kernel.org, willemb@google.com X-In-Reply-To: <20261124170551.1874487-3-willemdebruijn.kernel@gmail.com> X-sashiko-severity: Medium 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