From: Ido Schimmel <idosch@nvidia.com>
To: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Cc: netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, William Tu <witu@nvidia.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4] erspan: drop packets with an unknown ERSPAN version
Date: Sun, 15 Nov 2026 14:36:18 +0200 [thread overview]
Message-ID: <20261115123618.GA3993415@shredder> (raw)
In-Reply-To: <20261110152848.23136-1-yanhaishuang@cmss.chinamobile.com>
On Wed, Nov 11, 2026 at 12:28:48AM +0900, Haishuang Yan wrote:
> The ERSPAN type II and III receive paths take the length of the ERSPAN
> header from the version field of the packet, with erspan_hdr_len(), but
> never check that the version is one they know: 1 for type II or 2 for
> type III.
>
> For any other version, erspan_hdr_len() returns 0 or the type III
> length. With version 0, the ERSPAN header is not pulled, so it is
> passed up as the start of the inner Ethernet frame, and in collect_md
> mode the metadata is filled from the wrong part of the header. The
> ETH_HLEN pull in __iptunnel_pull_header() still covers the bytes that
> are copied, so nothing is read past the pulled data.
>
> Reject such packets, as a packet with a truncated ERSPAN header already
> is.
>
> On IPv4, a packet with a 4-byte GRE header is taken as type I without
> looking at the protocol. gre_parse_header() treats an ETH_P_ERSPAN2
> packet as carrying an ERSPAN header whatever the GRE header length,
> but erspan_rcv() then skips that header's version and passes it up as
> the inner frame. Type I only uses ETH_P_ERSPAN, so check the protocol
> too. Such a packet now goes through the type III path and its version
> check.
>
> IPv6 has no type I, but ip6erspan_rcv() does not reject a type I
> packet, an ETH_P_ERSPAN packet with a 4-byte GRE header. Such a packet
> has no ERSPAN header, so the version is read from the inner destination
> MAC address, and if that happens to be 1 or 2, the start of the inner
> frame is stripped as an ERSPAN header. Reject these packets too.
>
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
prev parent reply other threads:[~2026-11-15 12:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 15:28 Haishuang Yan
2026-11-15 12:36 ` Ido Schimmel [this message]
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=20261115123618.GA3993415@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=witu@nvidia.com \
--cc=yanhaishuang@cmss.chinamobile.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®