Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6017499ybc; Wed, 27 Nov 2019 13:29:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxBKCW0mmnJsVQv1Di5k5IveB9WiQ+B7XSP4NxGW2vjdIwD1O/0osHhR7uwsBG1KPtBMGqj X-Received: by 2002:a17:906:13d5:: with SMTP id g21mr50734234ejc.72.1574890146090; Wed, 27 Nov 2019 13:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890146; cv=none; d=google.com; s=arc-20160816; b=gl/HSysto8sKpGdVqgCy7q65ZE4dDTU8GXBm7pet96+VvOI36ui1pisoHj/w6un4wi Re59gTRnlumrOVqDLzVfAeb7+ClW0fi5WBk0cNXTAVi1/4rKVbFvFkN1KdhMSZspUIAN iSUIw7otjfl5AFhaY36ujPgXQTuznwPPZtyESZgNmNv5ZcVQ1sf/UJ7NMk96fgOzUG/F vgXAlgSho3kPCMX/3W/hq9Y0RsnCh9jQmFWaGZNzoAnn2RPzyg00U59/KO3GhT00qdIZ WcKuN8Z0QQi6htRRXF9pe7vtBkj6+CaZkPnDgyO3+Kr7X88wQawK2Nc18qqQkD6uQLOU YQdw== 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=ibjWPRKT7zd+JSn1LqI1WGcqkJanVZRnX4roPC8DGQw=; b=STw7USIIuVYHR4jbZgyNQQgYh8QQnDHyp6M3SRDikUuC3HqaF5ccFhxAiwkuGfn6oY EEcIQkGn97DpJJ3aqVXxOGUwp2Pt0BHD8leG3lt0TF326pWz8SjHAxGErKiWg6fqnQke IkjSUk8Sc91byIIsR/vA0rdGCdN8xkPdhhAl6OPpoKXdmr1lu41F7tsrhdjomr6yvjq9 8G1gkkRvm5NKb94y/QlalrAVlkhBcdTYBNX56GkBE+HNMa0N/vB4VBkpXplCDa5L6Mad L/eaQr8IjBe00dl6yO9mBy1zanHh8NJtjYfhZ75n/sWBEYhHhzARr1+vPA2DAjTq2Bg8 xYYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yMi5XBOl; 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 w10si954202edx.180.2019.11.27.13.28.42; Wed, 27 Nov 2019 13:29:06 -0800 (PST) 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=yMi5XBOl; 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 S1732016AbfK0VDQ (ORCPT + 99 others); Wed, 27 Nov 2019 16:03:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:56360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732014AbfK0VDN (ORCPT ); Wed, 27 Nov 2019 16:03:13 -0500 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 2A88C21850; Wed, 27 Nov 2019 21:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888592; bh=Hkb8CNfhy9QgqCbkcvJJlCm1/a3KGg7NG2/yzxtl838=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yMi5XBOlpCJBcTLFBGLgNoov26E9MSGTRKOySKdYS5htRbi243LXQHtaILO1aB4o9 EAGG6AurlF+mjU7DBuypGIohFg2zaSvwYOQ+LkIxrHTNYhyhmrhui9yawksLdxTte2 uvlb+pKVoHnkxwfn4XoAOnoJSC5D0ENWpLn+I7Uk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Song Liu , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.19 142/306] bpf: devmap: fix wrong interface selection in notifier_call Date: Wed, 27 Nov 2019 21:29:52 +0100 Message-Id: <20191127203125.715486640@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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: Taehee Yoo [ Upstream commit f592f804831f1cf9d1f9966f58c80f150e6829b5 ] The dev_map_notification() removes interface in devmap if unregistering interface's ifindex is same. But only checking ifindex is not enough because other netns can have same ifindex. so that wrong interface selection could occurred. Hence netdev pointer comparison code is added. v2: compare netdev pointer instead of using net_eq() (Daniel Borkmann) v1: Initial patch Fixes: 2ddf71e23cc2 ("net: add notifier hooks for devmap bpf map") Signed-off-by: Taehee Yoo Acked-by: Song Liu Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- kernel/bpf/devmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index fc500ca464d00..1defea4b27553 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -520,8 +520,7 @@ static int dev_map_notification(struct notifier_block *notifier, struct bpf_dtab_netdev *dev, *odev; dev = READ_ONCE(dtab->netdev_map[i]); - if (!dev || - dev->dev->ifindex != netdev->ifindex) + if (!dev || netdev != dev->dev) continue; odev = cmpxchg(&dtab->netdev_map[i], dev, NULL); if (dev == odev) -- 2.20.1