From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E631DFC6195 for ; Fri, 8 Nov 2019 18:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBE1A22509 for ; Fri, 8 Nov 2019 18:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239572; bh=v9PPuIRY93R4lGfaNyPfFvpC2mtDl2BYQVLPH+Ij+Yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OwnowIEcfjE6uSw5IkE3arglh86Mbn0q2/3KVb1ghhQUrWYFrtTgJ8d+1KNOStKRm GcWtGP8VP7mV3AGcj5H6tnVpjjRFJeHYeLqaiT0IFk63V2LGAOKhLxiVWg9jb8bMJJ 7Fh1OfV/V1FNSlsh0/biDETV1mqOtymyDBVkVEws= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389023AbfKHS7a (ORCPT ); Fri, 8 Nov 2019 13:59:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:56336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388926AbfKHS73 (ORCPT ); Fri, 8 Nov 2019 13:59:29 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B3DA02255C; Fri, 8 Nov 2019 18:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239569; bh=v9PPuIRY93R4lGfaNyPfFvpC2mtDl2BYQVLPH+Ij+Yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NRfG0CdDlHDoGXJ8AqdeJ2FTvu+H/l/R3+yxNxoM296xCqcf5HVWFRmcr55tds4mR RoFprwi0KIMaS+UToGZgBTTwP0/j/hXh5+ySmyOLoaA5v32HQoj9gtugjF9SW2fqhS Xm5YAyuRPOTF8nW2xfPLnciFmpdwJnsuetIaNg04= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Long , "David S. Miller" Subject: [PATCH 4.14 47/62] erspan: fix the tun_info options_len check for erspan Date: Fri, 8 Nov 2019 19:50:35 +0100 Message-Id: <20191108174752.161636977@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174719.228826381@linuxfoundation.org> References: <20191108174719.228826381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xin Long [ Upstream commit 2eb8d6d2910cfe3dc67dc056f26f3dd9c63d47cd ] The check for !md doens't really work for ip_tunnel_info_opts(info) which only does info + 1. Also to avoid out-of-bounds access on info, it should ensure options_len is not less than erspan_metadata in both erspan_xmit() and ip6erspan_tunnel_xmit(). Fixes: 1a66a836da ("gre: add collect_md mode to ERSPAN tunnel") Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_gre.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -592,6 +592,9 @@ static void erspan_fb_xmit(struct sk_buf truncate = true; } + if (tun_info->options_len < sizeof(*md)) + goto err_free_rt; + md = ip_tunnel_info_opts(tun_info); if (!md) goto err_free_rt;