From patchwork Tue Mar 17 10:53:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 229298 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 9D0A7C10F29 for ; Tue, 17 Mar 2020 11:09:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 730DB20658 for ; Tue, 17 Mar 2020 11:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584443375; bh=CzhHUytA7PQRXPkW2ge9yrecruQxGowqk3W4wsgJEmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RWY7qley+x6CStW3iu66NQubojBj2eDxMgaDL1kufz5EUjB32HbLSW/xweOY1OBN0 peUaM8q81wo+IiJiX0FOKlvexAAexuG+cY8c04mUz5M/0KeYjeDS6SN7jRdYDYUoKZ nWxc2/kQyY9Xqko9repTZkhOfrIVT7Fdsc3gBt94= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728953AbgCQLJe (ORCPT ); Tue, 17 Mar 2020 07:09:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:51910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbgCQLJc (ORCPT ); Tue, 17 Mar 2020 07:09:32 -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 CCCC620752; Tue, 17 Mar 2020 11:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584443372; bh=CzhHUytA7PQRXPkW2ge9yrecruQxGowqk3W4wsgJEmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1E44UMMPLc9h8pBE5FCGrmH7xFkR/oObCbUI4wTY3V6nCdcyaTQRqsgSSK9nhOpJ5 JPujgfbgwpEDvY0KbYZR4w4Lmdjf0XbwGk6rsssAkaSiCAPG8p1tAB5iw1ZRvvY/m2 PCzNjvkaeSc+vE2YkuRBYcCiKujJPXQ+cZytV4VM= 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 5.5 013/151] ipvlan: dont deref eth hdr before checking its set Date: Tue, 17 Mar 2020 11:53:43 +0100 Message-Id: <20200317103327.384046085@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317103326.593639086@linuxfoundation.org> References: <20200317103326.593639086@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: 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 @@ -499,19 +499,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);