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=ham 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 A253CC4332D for ; Thu, 19 Mar 2020 13:11:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A8E92145D for ; Thu, 19 Mar 2020 13:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623495; bh=nOADCBPFTAIRjOeiOmXpOXpC+G5KCw0hroB8KVfhh3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xZhkC5GhnUcMoNGHnAiSSF4k7HjSTIJHuq+M/MG/zgOdEvYU/AFE3+WD9k5P0nHET pGXSOiXbVg00iMBbf/oT0UDcqWTmecTXDFHnn9T8ccU07lwp3n0CsV3kPmGBCyB3bo h/2VZUqvF9YGCo1BV5vP9Et0TktJwOcwo6XKTP2Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbgCSNLe (ORCPT ); Thu, 19 Mar 2020 09:11:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:56654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727806AbgCSNL1 (ORCPT ); Thu, 19 Mar 2020 09:11:27 -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 1165220722; Thu, 19 Mar 2020 13:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623486; bh=nOADCBPFTAIRjOeiOmXpOXpC+G5KCw0hroB8KVfhh3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wOPgcCdLm3mZexr1F7hvPfmOfYi0qeaPg1HzfET10g31C+QGDKb+1toTzVmqFHgl/ K0A0cj6OoA7Iw0HwnKbN+s0kLJKB/rpC78vA8nhoDSBsbcsIzXuCZKeZGF0tfGaqk1 hPCGLT2peVUyAsGz/Z6+tAsUIScXk2743mnYa/AM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mahesh Bandewar , Eric Dumazet , "David S. Miller" Subject: [PATCH 4.9 24/90] ipvlan: dont deref eth hdr before checking its set Date: Thu, 19 Mar 2020 13:59:46 +0100 Message-Id: <20200319123936.081546659@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123928.635114118@linuxfoundation.org> References: <20200319123928.635114118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mahesh Bandewar [ Upstream commit ad8192767c9f9cf97da57b9ffcea70fb100febef ] IPvlan in L3 mode discards outbound multicast packets but performs the check before ensuring the ether-header is set or not. This is an error that Eric found through code browsing. Fixes: 2ad7bf363841 (“ipvlan: Initial check-in of the IPVLAN driver.”) Signed-off-by: Mahesh Bandewar Reported-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ipvlan/ipvlan_core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) --- a/drivers/net/ipvlan/ipvlan_core.c +++ b/drivers/net/ipvlan/ipvlan_core.c @@ -444,19 +444,21 @@ static int ipvlan_process_outbound(struc struct ethhdr *ethh = eth_hdr(skb); int ret = NET_XMIT_DROP; - /* In this mode we dont care about multicast and broadcast traffic */ - if (is_multicast_ether_addr(ethh->h_dest)) { - pr_debug_ratelimited("Dropped {multi|broad}cast of type=[%x]\n", - ntohs(skb->protocol)); - kfree_skb(skb); - goto out; - } - /* The ipvlan is a pseudo-L2 device, so the packets that we receive * will have L2; which need to discarded and processed further * in the net-ns of the main-device. */ if (skb_mac_header_was_set(skb)) { + /* In this mode we dont care about + * multicast and broadcast traffic */ + if (is_multicast_ether_addr(ethh->h_dest)) { + pr_debug_ratelimited( + "Dropped {multi|broad}cast of type=[%x]\n", + ntohs(skb->protocol)); + kfree_skb(skb); + goto out; + } + skb_pull(skb, sizeof(*ethh)); skb->mac_header = (typeof(skb->mac_header))~0U; skb_reset_network_header(skb);