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 1EAE3C4332D for ; Thu, 19 Mar 2020 13:32:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5F25207FC for ; Thu, 19 Mar 2020 13:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584624731; bh=Q2//7LMYHPT4m/e49/5TW2QLXyQ8CiC3vMHH3sI2Ur0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BQAVmoD8O+scjVzMnMIJoDE9+Ilz2DMn03Ka0iErZco4KbR9KiJqPglhPBjzAO8Dz rqUuvqgV36irttsFoQ+b6FU3TO6KOBkeqxU9XVULgtTNucy38RDanAM7Ys6r8eOENr vOD9fJGaOLOCC5neBNRt0bAWks2Vtaaxxr/Cp2mM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729416AbgCSNQh (ORCPT ); Thu, 19 Mar 2020 09:16:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:36906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729169AbgCSNQ3 (ORCPT ); Thu, 19 Mar 2020 09:16:29 -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 7B87120724; Thu, 19 Mar 2020 13:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623789; bh=Q2//7LMYHPT4m/e49/5TW2QLXyQ8CiC3vMHH3sI2Ur0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RiiG3yqhxt6+fX5ra9n2N7L1zYD5JDloP/iyqo2rvPpfVJ+pw+R6ai2NrHd8CBlx3 +dqZU7bnY3mVix0KF+mPAlxa514Y0mBzZh+nEFrjoh5tLohP2yQNCLWZhTBa4PhmwG Sl2iWKUwp7Io5vwRdFTCEmsyXhydvkq0uJwJnlRY= 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.14 36/99] ipvlan: dont deref eth hdr before checking its set Date: Thu, 19 Mar 2020 14:03:14 +0100 Message-Id: <20200319123952.780723528@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123941.630731708@linuxfoundation.org> References: <20200319123941.630731708@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 @@ -449,19 +449,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);