public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: pabeni@redhat.com
Cc: Simon Horman <horms@kernel.org>,
	petrm@nvidia.com, willemdebruijn.kernel@gmail.com,
	shuah@kernel.org, sdf@fomichev.me, idosch@nvidia.com,
	davem@davemloft.net, netdev@vger.kernel.org,
	andrew+netdev@lunn.ch, edumazet@google.com,
	donald.hunter@gmail.com, razor@blackwall.org, kuba@kernel.org
Subject: Re: [v5,net-next,08/10] geneve: extract hint option at GRO stage
Date: Fri, 23 Jan 2026 17:53:13 +0000	[thread overview]
Message-ID: <20260123175313.1286366-1-horms@kernel.org> (raw)
In-Reply-To: <cd0e9dc42ba83f388b604097cffe268ffcb53351.1769011015.git.pabeni@redhat.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
geneve: extract hint option at GRO stage

This patch adds helpers for finding and validating a GRO hint option in
the geneve header and uses them to extract hint info at the GRO stage.

> diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> index a4c23240d9e3..2e1f85b8af4e 100644
> --- a/drivers/net/geneve.c
> +++ b/drivers/net/geneve.c

[ ... ]

> +static unsigned int
> +geneve_opt_gro_hint_off(const struct genevehdr *gh, __be16 *type,
> +			unsigned int *gh_len)
> +{

[ ... ]

> +	*type = proto_id_map[id];
> +	*gh_len += gro_hint->nested_hdr_len;
> +
> +	return (void *)gro_hint - (void *)gh;
> +}

[ ... ]

> @@ -541,13 +700,13 @@ static struct sk_buff *geneve_gro_receive(struct sock *sk,
>  					  struct list_head *head,
>  					  struct sk_buff *skb)
>  {
> +	unsigned int hlen, gh_len, off_gnv, hint_off;

[ ... ]

> +	/* The GRO hint/nested hdr could use a different ethernet type. */
> +	hint_off = geneve_sk_gro_hint_off(sk, gh, &type, &gh_len);

When geneve_sk_gro_hint_off() succeeds (hint_off != 0), gh_len is increased
by nested_hdr_len. The current packet is then validated for this larger
size via skb_gro_header().

> +	if (hint_off) {
> +		const struct geneve_opt_gro_hint *gro_hint;
> +
> +		/*
> +		 * If the hint is present, and nested hdr validation fails, do
> +		 * not attempt plain GRO: it will ignore inner hdrs and cause
> +		 * OoO.
> +		 */
> +		gh = skb_gro_header(skb, off_gnv + gh_len, off_gnv);
> +		if (unlikely(!gh))
> +			goto out;
> +
> +		gro_hint = geneve_opt_gro_hint(gh, hint_off);
> +		if (!geneve_opt_gro_hint_validate_csum(skb, gh, gro_hint))
> +			goto out;
> +	}
> +
>  	list_for_each_entry(p, head, list) {
>  		if (!NAPI_GRO_CB(p)->same_flow)
>  			continue;
>
>  		gh2 = (struct genevehdr *)(p->data + off_gnv);
>  		if (gh->opt_len != gh2->opt_len ||
>  		    memcmp(gh, gh2, gh_len)) {
                            ^^^^^^

When the current packet has a hint option and gh_len has been increased to
include nested_hdr_len, the memcmp reads gh_len bytes from gh2. However,
packet p in the GRO list may have been processed without a hint option
(even on the same socket, if the packet itself lacks the geneve hint
option), meaning it was only validated for geneve_hlen() bytes.

Could memcmp read beyond the validated region of packet p? The socket can
have gro_hint enabled while individual packets may or may not contain the
hint option. If p lacks the option, it was validated for a smaller size
than gh_len.

Note: this appears to be addressed in the next patch in the series
(566c51bcb23e "geneve: use GRO hint option in the RX path") which
introduces geneve_hdr_match() that recalculates gh_len = geneve_hlen(gh)
before the memcmp and handles nested header comparison separately.

> @@ -580,7 +759,6 @@ static struct sk_buff *geneve_gro_receive(struct sock *sk,
>
>  	skb_gro_pull(skb, gh_len);
>  	skb_gro_postpull_rcsum(skb, gh, gh_len);

  parent reply	other threads:[~2026-01-23 17:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-21 16:11 [PATCH v5 net-next 00/10] geneve: introduce double tunnel GSO/GRO support Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 01/10] net: introduce mangleid_features Paolo Abeni
2026-01-21 16:15   ` Eric Dumazet
2026-01-23 19:32   ` Jakub Kicinski
2026-01-21 16:11 ` [PATCH v5 net-next 02/10] geneve: expose gso partial features for tunnel offload Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 03/10] vxlan: " Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 04/10] geneve: add netlink support for GRO hint Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 05/10] geneve: constify geneve_hlen() Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 06/10] geneve: pass the geneve device ptr to geneve_build_skb() Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 07/10] geneve: add GRO hint output path Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 08/10] geneve: extract hint option at GRO stage Paolo Abeni
2026-01-22 14:57   ` Paolo Abeni
2026-01-23 17:54     ` Simon Horman
2026-01-23 17:53   ` Simon Horman [this message]
2026-01-21 16:11 ` [PATCH v5 net-next 09/10] geneve: use GRO hint option in the RX path Paolo Abeni
2026-01-21 16:11 ` [PATCH v5 net-next 10/10] selftests: net: tests for add double tunneling GRO/GSO Paolo Abeni
2026-01-22 10:05   ` Petr Machata
2026-01-23 19:33 ` [PATCH v5 net-next 00/10] geneve: introduce double tunnel GSO/GRO support Jakub Kicinski
2026-01-26 14:15   ` Paolo Abeni
2026-01-23 19:50 ` patchwork-bot+netdevbpf

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=20260123175313.1286366-1-horms@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.org \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=willemdebruijn.kernel@gmail.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