Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp265753img; Mon, 18 Mar 2019 02:37:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYwNQPcp4WIUgMaeIGAhHM1kRUVAZLeVjuB316dUZQ8BHZB/J6kkdVqhBHWX5izZzRguCT X-Received: by 2002:a63:ef57:: with SMTP id c23mr6694370pgk.176.1552901854307; Mon, 18 Mar 2019 02:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901854; cv=none; d=google.com; s=arc-20160816; b=0fxRmRa4O7QurjXNyMM5P2Ao5Wov10Pg20hS1DzS/2aprMGQnzkSGklIVKMN7/Nfae zx8aRIwtUkjZOSAqOdL9Xg43C7lX5MuBcIZn9YBnhIE07Xfcgn92KPsHIkghlxTCxpN2 9pr7Vw7261jDEJ+M+Ngp79brNATe1q8R93vcqj0H/k6pi/pjrTXhY0pIYBG+lYPJwVQK NGN6KezcTHsfUNG4zrHx0KsMfei0DEyBKHvI+4uO9OM2npiODHRFmqrILWZQnBF43C39 rFRjXdj+RfF3cGGzyUPFcsyuCPg/0CyA98MHv7Bvi7ICMjsXFyGcI9kEsD9V8UjYLsTi qIGg== 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=+K3cXBAQa6iKDX4Ud26kOsGWOjROjeghsl9o+DxN3jM=; b=X+BzxWbZey5AgQJ4oZjqovxliLGh35fT35G867PJKxVERx3ekZC2/rRKnkyqFtTeJI KILOe0/urStrhe9bWmH1IJTCw5DyA2XrRP6BB0iSLo7m1y8dznCYSpHKIKyiBpgvhALs HYV/A9iFWhd5Eo4Q3axWe8aYIxGPk+pYuO959f7QrnX3fNzomihqOHyYVO0MxM9rDp+N 8sw/Qh3YabmRPhoNRIiXd9BxlfbM49AuK83We2YilJLDbYC2NO0FsCleZvRdOm2UhaCt COUI8vB7T/0ElFpx5KaHZUkaupdInLKZuNBDGRXP9zGNFKALR2cXAYjD9BRcfZBkcfV/ 5+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KMwmwrh0; 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 i4si8168212pgs.408.2019.03.18.02.37.19; Mon, 18 Mar 2019 02:37:34 -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=KMwmwrh0; 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 S2387535AbfCRJft (ORCPT + 99 others); Mon, 18 Mar 2019 05:35:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:44160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387525AbfCRJfr (ORCPT ); Mon, 18 Mar 2019 05:35:47 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.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 6A59E2083D; Mon, 18 Mar 2019 09:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901746; bh=D5T1vFrT2qMlYWnGN5huLS65tqFi99JzKt35bf8ZcZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMwmwrh0sdFeYZXlcJBFGj9/ifRqJzwXmKcb57HeT6gWKc+ZAhvBNl4EngjiPTbyr sh8q3MT0pG9V6aXA4HAvy+hv3vtsswscKhtqy4qdir113mxVQQM2JdnJriYolS/FDl asaKe7YKAPUfKTM+0smlwYq0rjiIVVWo0I55Pey4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tianhao Zhao , Paolo Abeni , David Ahern , "David S. Miller" Subject: [PATCH 4.14 04/34] ipv4/route: fail early when inet dev is missing Date: Mon, 18 Mar 2019 10:25:28 +0100 Message-Id: <20190318084145.238752150@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318084144.657740413@linuxfoundation.org> References: <20190318084144.657740413@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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Abeni [ Upstream commit 22c74764aa2943ecdf9f07c900d8a9c8ba6c9265 ] If a non local multicast packet reaches ip_route_input_rcu() while the ingress device IPv4 private data (in_dev) is NULL, we end up doing a NULL pointer dereference in IN_DEV_MFORWARD(). Since the later call to ip_route_input_mc() is going to fail if !in_dev, we can fail early in such scenario and avoid the dangerous code path. v1 -> v2: - clarified the commit message, no code changes Reported-by: Tianhao Zhao Fixes: e58e41596811 ("net: Enable support for VRF with ipv4 multicast") Signed-off-by: Paolo Abeni Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/route.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2123,12 +2123,13 @@ int ip_route_input_rcu(struct sk_buff *s int our = 0; int err = -EINVAL; - if (in_dev) - our = ip_check_mc_rcu(in_dev, daddr, saddr, - ip_hdr(skb)->protocol); + if (!in_dev) + return err; + our = ip_check_mc_rcu(in_dev, daddr, saddr, + ip_hdr(skb)->protocol); /* check l3 master if no match yet */ - if ((!in_dev || !our) && netif_is_l3_slave(dev)) { + if (!our && netif_is_l3_slave(dev)) { struct in_device *l3_in_dev; l3_in_dev = __in_dev_get_rcu(skb->dev);