Article View: linux.kernel.netdev
Article #12637Re: [PATCH net-next v2] erspan: drop packets with an unknown ERSPAN version
From: netdev-bot+sashiko
Date: Sun, 08 Nov 2026 05:03
Date: Sun, 08 Nov 2026 05:03
95 lines
10996 bytes
10996 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
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] The new version check can be bypassed: an ETH_P_ERSPAN2 (type
III) frame with a 4-byte GRE header never reaches it.
--
erspan: drop packets with an unknown ERSPAN version
This patch makes erspan_rcv() and ip6erspan_rcv() reject packets whose
ERSPAN version field is not 1 (type II) or 2 (type III). Before this,
such packets either had no ERSPAN header pulled or were given the type
III length.
> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
> index 5485586fa0e62..ea41be3c4229b 100644
> --- a/net/ipv4/ip_gre.c
> +++ b/net/ipv4/ip_gre.c
> @@ -303,8 +303,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
> if (tunnel) {
> if (is_erspan_type1(gre_hdr_len))
> len = gre_hdr_len;
> - else
> + else if (ver == ERSPAN_VERSION || ver == ERSPAN_VERSION2)
> len = gre_hdr_len + erspan_hdr_len(ver);
> + else
> + return PACKET_REJECT;
[Severity: Medium]
Can an ETH_P_ERSPAN2 frame with a 4-byte GRE header get around this new
check?
is_erspan_type1() looks only at gre_hdr_len and never checks
tpi->proto:
net/ipv4/ip_gre.c:is_erspan_type1() {
/* Both ERSPAN type I (version 0) and type II (version 1) use
* protocol 0x88BE, but the type I has only 4-byte GRE header,
* while type II has 8-byte.
*/
return gre_hdr_len == 4;
}
gre_parse_header() treats ETH_P_ERSPAN2 (0x22EB, defined in uAPI as
type III) as always carrying an ERSPAN base header, whatever hdr_len
is:
net/ipv4/gre_demux.c:gre_parse_header() {
...
if ((greh->protocol == htons(ETH_P_ERSPAN) && hdr_len != 4) ||
greh->protocol == htons(ETH_P_ERSPAN2)) {
...
tpi->key = cpu_to_be32(get_session_id(ershdr));
}
...
}
gre_rcv() then calls erspan_rcv(skb, &tpi, 4). Since
is_erspan_type1(4) is true, ver is forced to 0 and the lookup uses
NO_KEY with key 0. That can match a keyless erspan_ver 0 tunnel or the
collect_md fallback in ip_tunnel_lookup().
>From there len = gre_hdr_len and the new version check is skipped. An
ERSPAN header with any version (0 or 3..15) is passed up as the start
of the inner Ethernet frame, which is the outcome the commit message
says is fixed.
In collect_md mode, tun_id = key32_to_tunnel_id(tpi->key) is also built
from the session ID in those 4 bytes, and the same bytes are handed up
as the inner MAC header.
__iptunnel_pull_header() still pulls ETH_HLEN, so nothing is read out
of bounds.
Would it make sense to also require tpi->proto == htons(ETH_P_ERSPAN)
when classifying a packet as type I, so this path is covered too?
>
> if (unlikely(!pskb_may_pull(skb, len)))
> return PACKET_REJECT;
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107130030.35220-1-yanhaishuang%40cmss.chinamobile.com
Technical Details
Message-ID:
<179411422969.994134.8902723149137301857@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-358589-linux-kernel-netdev=dewy.ruReferences:
<20261107130030.35220-1-yanhaishuang@cmss.chinamobile.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-358589-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2] erspan: drop packets with an unknown ERSPAN version Date: Sun, 08 Nov 2026 05:03:49 +0000 Organization: Usenet Network Message-ID: <179411422969.994134.8902723149137301857@kernel.org> References: <20261107130030.35220-1-yanhaishuang@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="65053"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:D6gOSHLtEcHrADEhogDZk+cobyA= sha256:rOSjLJsqLG8yeMpIhzJAeKB6mnCtDmmnaT7CnlECwiY= sha1:eBczpiqZcIfp7uEtI4eE6B/Fvww= sha256:Kag57ETAYQ0X51TRgCfBPg+jj0szl4GblBCOmRAIm8g= 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 88E1D1134ED; Sun, 8 Nov 2026 08:05:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 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, 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 IsPcp6OFCgP7; Sun, 8 Nov 2026 08:05:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358589-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 6D1AC113391; Sun, 8 Nov 2026 08:04:52 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 10A783D5B9; Sun, 8 Nov 2026 05:04:06 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1794114237; b=VaEg/BkBFxNmwpJjkLYAUUX4gruLq105+n8F4L/2YMLdOztBBo3D/O0xzy0EAHAzPuA2 2FGgAn0hzCvuevrW0MSrV6rLQB+FDt8McxYvNU9A1sN7G4Ml28eiYu2mjnsNScklhnX34 wH+VoLZOL+oNkGbljBL7Sb9xWQWJ96siB4v3UOpwnnr/gzrVgPIIXtES2xAaM202dPWr0 HXlzmCK9ZTXQfjJVi8ajPBSVgmsONWkBa5Rhby7eIxRB+Q6C+YlBb5adEeEvbejNXo7tX g/rs2GSj2VJ02L0xHq1Fz2A1FeFj9TdXKj5zlBpizAekmF1W8/Xzh/QOCPzPVgtaxuA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794114237; 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=a+JbwsepHx9Uk2AzsEX7xxvXiLmEyOWKB/M2T5kLRG4=; b=fA4q3PUaUHTOJ/E/QfSG5RikNxAW1x87R2oMyBjaV5VAS8pNjPJypBiYffeIZrKk4x+M HjCGTJ8bOuoPvVHCrfL9rMQM9ugwfuWhtS0Mdu7/jE00TNasw8pojjrVHQRwnb7G9L+MM 8V/GfKzn3jrvwGkPLQtJvlUDNFv6NX3kJZjGuMUloRt9t3yKJtdeLIzH+3ZJueYGia5Id q1vMAc/T1GPLFQHNYx+s7AjIwvfrDlMJc5Ali7tJ3+4A2ovYDHMXz5t91gf+/pBvAc5G9 tMoziXAnlzSrg849eQa0vVu4JGjvTHVgy5o4mPTMTqV1f4Q+IILQvhmlZQiv561dXEg== 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=hBIaTmaZ; arc=fail 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 8FEFE606A334; Sun, 8 Nov 2026 05:03:57 +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=hBIaTmaZ 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=1794114231; b=dpHE4Punzze+/Fca1D6WDIGlJfwdw1pYaZJWbzoqorYhrSuzAClrpmq+8AsZPRNQlWQh CgTrE+BK7HQfL/c8zZytjEq7CuLhQFfKJ9rZZRrj6x6XOgU9J1Uf6+iPx7eaAXJUfYmMD uS9E1UNXR4uFGZ+dRNbBvCu6AJNPUIkdBPwipPxU2xYYL/WKcANq8L8SgjzY6waX7fKX7 lPs9DwyNQvbFx1KDNXWAAE47Mcnl3J7+Y2ux91TvFCP1V2xcJaqBwgR0+fKC8NH+t8m40 PBkG5fbcBGOau7PuQ/4NBFSKnyG3HJ057Btl/S6DxjXiYMwgml7/bGiQM70oxgaZhPg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794114231; 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=a+JbwsepHx9Uk2AzsEX7xxvXiLmEyOWKB/M2T5kLRG4=; b=Q8CTpdE9jgsGwG6CU9R2lmbm6uJp54YX8ZCgSNV0VHIk/D+VVxzi+SZkUsJ5RYSohcCv q8EkphWs4lZgKKNrmo9s4gd+aQnCfHIQf3rFKUDLQDO01p9kwZS8O9zAOpmqSWtXZUMC4 NWKDi82pHRqF6cfdNKY0BOg5C67w+a6GC51MLOhlrsCxQGW4G7MGgHJ4iLF4wP96/XFIO B458Kjt/SXN+ZP/LZvINCx6yKTaYQ/spnpXVqb+eFF3qHcydYM9YjBMclY76C4EAZ35dI rktdq+IA0ioY1gf7PEc828/S+fLgWjVyI9ggUcfV4swRrHEE3+GsPQeMSi1iazTx0Gw== 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=hBIaTmaZ; 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 6D182606A31A; Sun, 8 Nov 2026 05:03:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 382881F0089F; Sun, 8 Nov 2026 05:03:50 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794114230; bh=a+JbwsepHx9Uk2AzsEX7xxvXiLmEyOWKB/M2T5kLRG4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=hBIaTmaZeD8km6dArl4lJEQpIWcEB5RyPi6UioymbYW3QNlJ1rcRGCFnjZIcyK2s0 1bf9K5WBJkAR0VL2L8fF1/m9CkGyzbeC4eTgjZuHfyjkdkxhOPzx0CYjlzzA2TsAKU 5lPrtpPtY4Mam5MHzrOZO4t1N4rrdxAKWF9Q82dVe9klP9iOWD4KOxdE16hM4veUxL 23Xvm94gYdoUbiiS+5Qr4UIGzau8hzdlaXEvq78O0C1PaDTp+UE6Ax8s3TdAGUMDwK rXseucLMNSoI1OACw/5lEXcHnwW0BcpS6RLGoWZNkDOHmN2owyOS31KzyX2UqQbBF6 /lylpETjHXieg== X-Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, witu@nvidia.com, linux-kernel@vger.kernel.org X-In-Reply-To: <20261107130030.35220-1-yanhaishuang@cmss.chinamobile.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