Received: by 10.192.165.156 with SMTP id m28csp79785imm; Tue, 10 Apr 2018 16:52:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+hTnG08D4fFctY1o1NJSnj3L/EMdIqhwaGJNPSxxLtJ3Fy0E64JgiHqa1POdIhb1qYoZer X-Received: by 2002:a17:902:264:: with SMTP id 91-v6mr2537986plc.178.1523404351334; Tue, 10 Apr 2018 16:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404351; cv=none; d=google.com; s=arc-20160816; b=JOAI/nCtgkW004k9Guvek7Vpg6rlRYQmMNmEfbjqi0pFQPctXihy8PSQqqsoPtpx1v N9fQo7wa4p3rUJdd092GEkaAr2qj2yHzrVULyieay25gwe3GMA4pDFAIJVaVzpQd3Rt4 GwbjxT9CU5bQyLQb0egwxjQLBeaVdApBhFKeycMV2V0KM+zvD3MP9JtI4sZa3bGxZYc4 w8Ot7/EBkVXgFpUwLEhtK04H9PilVJ9h6eCkWBSNSaEY3AGyxBXkIHsMCDNGV/Er5tsH SQOP441c6ojV2/qXy8AIKP5Y6Q51wt1h911bUiU8H3/Ip1hXN0erqEcSSvRcKcjzMQmd HY7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2kLI1KA4W8u1HXdRgSmoUolsSip+tQj+cRjdG+5cxq0=; b=vNfRJKQNhzrpu8ywvBWU2Y1qFYd63jXQQPxw0tphh36HTDhn69VJ2GEhxfFLA0fx4w MUH0e5OotddJ9UovT+xnVcJw4jsoV2kxD4d/J65nDXgT8zMCs1OAzIFD6jF+ll8ZPP0H NqmgiWqfbPahxtPuSiWjSVWsTdP96jylITb31xOPfhqj8uXY5Je1hzrZK6iCS/8RyQKo twmk23JRdZdXwYNC7BlQr7TJ8+oo2TIIYCD56yNa21nCyshkbgXLyD3yvYajcNL5C/tK 9c2AR/uYxTPSUKbc8x8nMvDjv6inK+/J/YODqq3JfgVR8LSIUXbK8ZbavUrKbZxIfD0p WiKQ== ARC-Authentication-Results: i=1; mx.google.com; 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 m14si1256032pgs.190.2018.04.10.16.51.55; Tue, 10 Apr 2018 16:52:31 -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; 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 S1752275AbeDJWYR (ORCPT + 99 others); Tue, 10 Apr 2018 18:24:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36678 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624AbeDJWYO (ORCPT ); Tue, 10 Apr 2018 18:24:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8DBA5CFC; Tue, 10 Apr 2018 22:24:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Healy , Andrew Lunn , Florian Fainelli , "David S. Miller" Subject: [PATCH 4.16 03/18] net: dsa: Discard frames from unused ports Date: Wed, 11 Apr 2018 00:23:38 +0200 Message-Id: <20180410212758.734898358@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212758.564682823@linuxfoundation.org> References: <20180410212758.564682823@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrew Lunn [ Upstream commit fc5f33768cca7144f8d793205b229d46740d183b ] The Marvell switches under some conditions will pass a frame to the host with the port being the CPU port. Such frames are invalid, and should be dropped. Not dropping them can result in a crash when incrementing the receive statistics for an invalid port. Reported-by: Chris Healy Fixes: 91da11f870f0 ("net: Distributed Switch Architecture protocol support") Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/dsa/dsa_priv.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -126,6 +126,7 @@ static inline struct net_device *dsa_mas struct dsa_port *cpu_dp = dev->dsa_ptr; struct dsa_switch_tree *dst = cpu_dp->dst; struct dsa_switch *ds; + struct dsa_port *slave_port; if (device < 0 || device >= DSA_MAX_SWITCHES) return NULL; @@ -137,7 +138,12 @@ static inline struct net_device *dsa_mas if (port < 0 || port >= ds->num_ports) return NULL; - return ds->ports[port].slave; + slave_port = &ds->ports[port]; + + if (unlikely(slave_port->type != DSA_PORT_TYPE_USER)) + return NULL; + + return slave_port->slave; } /* port.c */