mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mst@redhat.com
Cc: linux-kernel@vger.kernel.org, willemdebruijn.kernel@gmail.com,
	jasowangio@gmail.com, eperezma@redhat.com,
	xuanzhuo@linux.alibaba.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	virtualization@lists.linux.dev, maxk@qualcomm.com,
	rusty@rustcorp.com.au, horms@kernel.org
Subject: Re: [PATCH net-next 2/4] net: use ip4_parse() in receive validation
Date: Wed, 14 Oct 2026 10:59:29 +0000	[thread overview]
Message-ID: <179197556904.434549.14572204986148873620@kernel.org> (raw)
In-Reply-To: <05eb0a83a9975e8e042caeeb4fca5fad30e02fb4.1791887415.git.mst@redhat.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message overstates how many sites were converted.

--

net: use ip4_parse() in receive validation

This patch converts br_validate_ipv4(), ip_rcv_core() and
nf_reject_iphdr_validate() to use ip4_parse(). They previously did an
open-coded pskb_may_pull() followed by version and ihl checks. The
returned thoff is then used in the later length checks.

> Convert the sites that pull and do version and ihl checks on the ipv4
> header and validate the packet transport offset to use ip4_parse.
>
> Sites that validate a read-only copy instead of pulling - the nft
> and nft_inner header_pointer validators, ip_check_defrag()'s
> skb_copy_bits, the flow dissector - stay open-coded for now.

[Severity: Low]
This isn't a bug, but is this description complete? A few sites still
call pskb_may_pull() and then open-code the version and ihl checks. The
read-only copy exclusion list above does not cover them.

nft_set_pktinfo_ipv4_ingress() in include/net/netfilter/nf_tables_ipv4.h:

	if (!pskb_may_pull(pkt->skb, sizeof(*iph)))
		return -1;

	iph = ip_hdr(pkt->skb);
	if (iph->ihl < 5 || iph->version != 4)
		goto inhdr_error;

This has the same pattern as br_validate_ipv4(). The header_pointer
validator in that file is __nft_set_pktinfo_ipv4_validate(), not this
function.

ip_mc_check_iphdr() in net/ipv4/igmp.c:

	if (!pskb_may_pull(skb, offset))
		return -EINVAL;

	iph = ip_hdr(skb);

	if (iph->version != 4 || ip_hdrlen(skb) < sizeof(*iph))
		return -EINVAL;

	offset += ip_hdrlen(skb) - sizeof(*iph);

	if (!pskb_may_pull(skb, offset))
		return -EINVAL;

This looks like it maps directly onto ip4_parse(skb,
skb_network_offset(skb), &thoff).

nf_ct_bridge_pre() in net/bridge/netfilter/nf_conntrack_bridge.c calls
pskb_may_pull(skb, sizeof(struct iphdr)). nf_ct_br_ip_check() then
checks:

	if (iph->ihl < 5 ||
	    iph->version != 4)
		return -1;

All three sites are still open-coded at the end of the series, after
"net: account for ingress-resolved virtio net hdr state". At that point
the only ip4_parse() callers are br_validate_ipv4(), ip_rcv_core(),
nf_reject_iphdr_validate() and include/linux/virtio_net.h.

A smaller point: ip_rcv_core() still sets the transport header from ihl,
even though thoff is now in scope:

	skb->transport_header = skb->network_header + iph->ihl*4;

This has no functional effect.

Should these sites be converted, or should the commit message list them
as staying open-coded?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1791887415.git.mst%40redhat.com

  reply	other threads:[~2026-10-14 10:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 10:58 [PATCH net-next 0/4] more virtio-net csum hardening Michael S. Tsirkin
2026-10-13 10:58 ` [PATCH net-next 1/4] net: add ip4_parse() Michael S. Tsirkin
2026-10-14 10:59   ` netdev-bot+sashiko
2026-10-13 10:58 ` [PATCH net-next 2/4] net: use ip4_parse() in receive validation Michael S. Tsirkin
2026-10-14 10:59   ` netdev-bot+sashiko [this message]
2026-10-13 10:58 ` [PATCH net-next 3/4] net: resolve uncommon partial checksums at ingress Michael S. Tsirkin
2026-10-13 11:06   ` Michael S. Tsirkin
2026-10-13 15:03     ` Willem de Bruijn
2026-10-13 18:35       ` Michael S. Tsirkin
2026-10-13 20:32         ` Willem de Bruijn
2026-10-13 20:38           ` Michael S. Tsirkin
2026-10-13 20:45             ` Willem de Bruijn
2026-10-13 20:51               ` Michael S. Tsirkin
2026-10-13 20:15       ` Michael S. Tsirkin
2026-10-14 10:59   ` netdev-bot+sashiko
2026-10-13 10:58 ` [PATCH net-next 4/4] net: account for ingress-resolved virtio net hdr state Michael S. Tsirkin
2026-10-13 17:45   ` Björn Töpel
2026-10-13 18:12     ` Michael S. Tsirkin
2026-10-14 10:59   ` netdev-bot+sashiko
2026-10-13 11:05 ` [PATCH net-next 0/4] more virtio-net csum hardening Michael S. Tsirkin
2026-10-13 18:51   ` Chris Arges
2026-10-13 14:41 ` Willem de Bruijn
2026-10-13 18:41   ` Michael S. Tsirkin
2026-10-13 20:29     ` Willem de Bruijn
2026-10-13 20:36       ` Michael S. Tsirkin
2026-10-13 20:54         ` Willem de Bruijn
2026-10-13 20:56           ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179197556904.434549.14572204986148873620@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=horms@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxk@qualcomm.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.linux.dev \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®