From patchwork Fri Jun 19 14:29:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223759 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 31EE5C433DF for ; Fri, 19 Jun 2020 16:30:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0040421527 for ; Fri, 19 Jun 2020 16:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592584222; bh=Tz0l8XZHBHCcqhE/18c0qkDSHj4sG4APZ4jK0ZbKGac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=voXwRwK/LU98deXiyi/tv5aZNTQCxryWWMh/F+6Xy/xZpMMdOVnW34xLHGzXyucte AD9SghXY9PiTROtYur7D0myq4ZqFSEulSNAnxUJC1FYpDSI44n4b4UxBbfyaGaRg8z yBt7Dfrac4gZycOFZJ47v1+TujFp6zlZ11xd7KEc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390053AbgFSQaP (ORCPT ); Fri, 19 Jun 2020 12:30:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:48398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389781AbgFSOxy (ORCPT ); Fri, 19 Jun 2020 10:53:54 -0400 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 119F8217D8; Fri, 19 Jun 2020 14:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578434; bh=Tz0l8XZHBHCcqhE/18c0qkDSHj4sG4APZ4jK0ZbKGac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dbgzzWDMjjRT5ShRewM842Tq7jRa4Tu4U9L+YmuAe0ZMPeNBH2TaZROGhPlZgRNPv +ED+zYc0EOg6nSAtjPZiTRlOCuKlmXaGdcCh6BJSRGmdgYcD8djIUoRwZEyVUbES87 spVgOn4P9gRld+P/WmsOqclTq3x54oi0Ayn1gXnA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Nikolay Aleksandrov , "David S. Miller" Subject: [PATCH 4.19 004/267] vxlan: Avoid infinite loop when suppressing NS messages with invalid options Date: Fri, 19 Jun 2020 16:29:49 +0200 Message-Id: <20200619141649.066202552@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ido Schimmel [ Upstream commit 8066e6b449e050675df48e7c4b16c29f00507ff0 ] When proxy mode is enabled the vxlan device might reply to Neighbor Solicitation (NS) messages on behalf of remote hosts. In case the NS message includes the "Source link-layer address" option [1], the vxlan device will use the specified address as the link-layer destination address in its reply. To avoid an infinite loop, break out of the options parsing loop when encountering an option with length zero and disregard the NS message. This is consistent with the IPv6 ndisc code and RFC 4886 which states that "Nodes MUST silently discard an ND packet that contains an option with length zero" [2]. [1] https://tools.ietf.org/html/rfc4861#section-4.3 [2] https://tools.ietf.org/html/rfc4861#section-4.6 Fixes: 4b29dba9c085 ("vxlan: fix nonfunctional neigh_reduce()") Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/vxlan.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1611,6 +1611,10 @@ static struct sk_buff *vxlan_na_create(s ns_olen = request->len - skb_network_offset(request) - sizeof(struct ipv6hdr) - sizeof(*ns); for (i = 0; i < ns_olen-1; i += (ns->opt[i+1]<<3)) { + if (!ns->opt[i + 1]) { + kfree_skb(reply); + return NULL; + } if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) { daddr = ns->opt + i + sizeof(struct nd_opt_hdr); break;