Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp578578img; Fri, 22 Mar 2019 04:26:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM+E3wHx6syjtxpPdrpgERNet/J8dQs2GpKzgLya5/i8NGA1bJMsbBEJfxj5PGvR4S0ffx X-Received: by 2002:a17:902:547:: with SMTP id 65mr9075576plf.242.1553253965993; Fri, 22 Mar 2019 04:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253965; cv=none; d=google.com; s=arc-20160816; b=VOAPAafabRTsnzKhhwD0ubK8UOigNxlOZfQ8F8SOmRjwXADVFefn9LR3yEolePe90D CgUHB7FbmytJT0tXt0+RhahxI5UFlnJtfTfPXRTkEWgqI0OYehDJPzI7HLMPVLHUIMGH WEXbGzGLOXrt4MiJ87+/gr3Dp0JS5XerP83YuQSDgt3nyQCXFFU9S8VRftb48Rndim3f hxM5S60y3XG4pGA5DpduoTHyHWx0Wh8ENWxYB4EhhXzza+OOrS7dugPEulGS2s+WdO+S A0N9WlA+iX/7X1S2tHDgk7tiXFlI3gPcj5oL7MMlmE91cA6PF8GvcvWQAi86HAEyMOZD QMYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mpa5Ur1vSPIAhSaI9QcFM9vHtErcDGZbmOwA1zLIitI=; b=BHksZi2bfY3EVYWfpcIEIsIT50EKSot7Jhclg+/Yne51LXYNfxt7vpRdZZoh7cNb0H cAt/U+OIgn2yG769K7ahLTMY+VgbeB8pI7w3sA6z9U+HAAxIAWe/ydEGUdFVngB5byBS 9TirAG+3c8se7K54pK90pubOtiLMR0HP6FWQR2kkWoYzUkld9YmNHvFRbxDXo1IkHQ1x 6xXjGaCK5q0vqXNwEvr44RPPSvJ03Oam47J00CTxzcro8EtEFJlfLD3ybqRVrM97yO1L XCvAdLZdPbGSwjFbXr3iQps2Jc+GQyEVh0bfbwq7Guv8t7DU/umwViMaxRxY3p+n1QGf 5jKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=psPTXIzR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si6249525pgp.581.2019.03.22.04.25.48; Fri, 22 Mar 2019 04:26:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=psPTXIzR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729067AbfCVLYM (ORCPT + 99 others); Fri, 22 Mar 2019 07:24:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:51180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729051AbfCVLYJ (ORCPT ); Fri, 22 Mar 2019 07:24:09 -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 DFF222190A; Fri, 22 Mar 2019 11:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253848; bh=JJygba01lzbxCWm5WyrhVfdt+t9b0Fbx2M5OMDx4qC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=psPTXIzRtJ2L22Ao6LIExYELZ/jOpe/RsByvKrtEeOU8AcbM9hVRPcDsvTOVqBESW dmN9AqqF1J0Onyzozpp2WyoQRGlYFidKYOqpSoR5fIGckI4ZTGL0da/JcvEEfzl3VR NGED0rMULwvC0qbzOcwPm0ZoQz9BbbX1e8Dy1JAg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 3.18 090/134] vxlan: test dev->flags & IFF_UP before calling gro_cells_receive() Date: Fri, 22 Mar 2019 12:15:03 +0100 Message-Id: <20190322111216.646001507@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 59cbf56fcd98ba2a715b6e97c4e43f773f956393 ] Same reasons than the ones explained in commit 4179cb5a4c92 ("vxlan: test dev->flags & IFF_UP before calling netif_rx()") netif_rx() or gro_cells_receive() must be called under a strict contract. At device dismantle phase, core networking clears IFF_UP and flush_all_backlogs() is called after rcu grace period to make sure no incoming packet might be in a cpu backlog and still referencing the device. A similar protocol is used for gro_cells infrastructure, as gro_cells_destroy() will be called only after a full rcu grace period is observed after IFF_UP has been cleared. Most drivers call netif_rx() from their interrupt handler, and since the interrupts are disabled at device dismantle, netif_rx() does not have to check dev->flags & IFF_UP Virtual drivers do not have this guarantee, and must therefore make the check themselves. Otherwise we risk use-after-free and/or crashes. Fixes: d342894c5d2f ("vxlan: virtual extensible lan") Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/vxlan.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1238,6 +1238,14 @@ static void vxlan_rcv(struct vxlan_sock } } + rcu_read_lock(); + + if (unlikely(!(vxlan->dev->flags & IFF_UP))) { + rcu_read_unlock(); + atomic_long_inc(&vxlan->dev->rx_dropped); + goto drop; + } + stats = this_cpu_ptr(vxlan->dev->tstats); u64_stats_update_begin(&stats->syncp); stats->rx_packets++; @@ -1246,6 +1254,8 @@ static void vxlan_rcv(struct vxlan_sock netif_rx(skb); + rcu_read_unlock(); + return; drop: /* Consume bad packet */