Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2274365pxb; Mon, 11 Jan 2021 05:47:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXyaeYxAD/7tpbsuW5hVOKDv+AvrRlJtNqNQ8DmUZ3ES8FxmtmB43nwD5kNGGb4uLQEULv X-Received: by 2002:a05:6402:149a:: with SMTP id e26mr14998423edv.150.1610372860104; Mon, 11 Jan 2021 05:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372860; cv=none; d=google.com; s=arc-20160816; b=sy6+RofKFj3RXYBOxTc/wynbl6G9jKzNBL/K4Dc8neQugH59YvJ/595YR6uWEh/nTm qr7lPxSw9GwLt8s37H1fjWjJ4WRNenC7vxAagapBLLB8OobGUbTgchPJ+dfrataOgN/A RvFrYwqZTEzA4mVG/vvOUGCUG8nrO+53bSs979ZClItNPfyqkA0PoSfYXfL6gyi/xnTY TVdCWoGmWwyVgoQxaVxyyJmymMe+e20GvqVB2haSGSwrKgKFOyTZ3AMPAQruIw1NdtKM 6VQ6FmV6ORBYbvESeTXP59qDYUT2BpPYjhB/vtVKNzVQXMwDhMV5jwBfEdC1ohurCZ06 a/9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b0cEReSYcyTLdCAMGR1JjdJ+6+i3p+SMjACOaQ+blA0=; b=RD6qXpiUChhZ/O/mb0/uufpc72k/hFJ8NPWcneb4eEbjOdO4Zcir4nq8zy9W/pMHDS oyI/mjyMv0KBxqTNHHBWqa7zerqqM2NE2ke1+N1l++nWt0N+p0s1XlawJyP3EEF6Ex0H kRdqt4PhpSOZhNnuq7JUfWQze9VSANe2rhfHziyqHrLji9rR8KniVRdjGBsmrbIcgRAD MvHutcCWPCBvAXp9YY2HTiuUeucg2rw+zjbj0bjfboQwgTjy4X7YuffFLrPKlbzr5sqB Y27iUqmkV89CyM3n2TpC1bEfR3sE3SoRsznjf+obSGOheJI3W3li4guJGs7LJXsoobZe 9WKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M+qh9Wj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si6842682eds.206.2021.01.11.05.47.16; Mon, 11 Jan 2021 05:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M+qh9Wj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730735AbhAKNLw (ORCPT + 99 others); Mon, 11 Jan 2021 08:11:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:57186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731302AbhAKNLA (ORCPT ); Mon, 11 Jan 2021 08:11:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D10922515; Mon, 11 Jan 2021 13:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370645; bh=V0YfpRdskoi1wo05n6BbXjnKr81nb/SjTlpJSVCI8tE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+qh9Wj+sHUtNtWR7AYJ7/jERoEcGuJ2nGLnFeenJQ7DcCaYZXTZ4Okd0mhLd8zlG u2u2/4xSaYsfk0x+EeiArnYF90sPPjaWBvdNp9tPyhG28Vv9dv2vFO+uXKARVQDa/s O5cAhuCfBCUJ53rsGxcntEdKUuYt96cxy4p+HmwQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+f583ce3d4ddf9836b27a@syzkaller.appspotmail.com, William Tu , Lorenzo Bianconi , Cong Wang , "David S. Miller" Subject: [PATCH 5.4 36/92] erspan: fix version 1 check in gre_parse_header() Date: Mon, 11 Jan 2021 14:01:40 +0100 Message-Id: <20210111130040.888957337@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cong Wang [ Upstream commit 085c7c4e1c0e50d90b7d90f61a12e12b317a91e2 ] Both version 0 and version 1 use ETH_P_ERSPAN, but version 0 does not have an erspan header. So the check in gre_parse_header() is wrong, we have to distinguish version 1 from version 0. We can just check the gre header length like is_erspan_type1(). Fixes: cb73ee40b1b3 ("net: ip_gre: use erspan key field for tunnel lookup") Reported-by: syzbot+f583ce3d4ddf9836b27a@syzkaller.appspotmail.com Cc: William Tu Cc: Lorenzo Bianconi Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/gre_demux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c @@ -128,7 +128,7 @@ int gre_parse_header(struct sk_buff *skb * to 0 and sets the configured key in the * inner erspan header field */ - if (greh->protocol == htons(ETH_P_ERSPAN) || + if ((greh->protocol == htons(ETH_P_ERSPAN) && hdr_len != 4) || greh->protocol == htons(ETH_P_ERSPAN2)) { struct erspan_base_hdr *ershdr;