Received: by 10.192.165.156 with SMTP id m28csp61008imm; Tue, 10 Apr 2018 16:24:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+NYXw1lsS43GCn6g0PcnTPdiJhKPSbWTpmbTffLik1GK66ZPMy7vRpuaF9QthoQ4BfJfJy X-Received: by 10.98.202.212 with SMTP id y81mr1934428pfk.227.1523402661030; Tue, 10 Apr 2018 16:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402661; cv=none; d=google.com; s=arc-20160816; b=m0DTkezIPl3fdx+rJiEfCHhVw88b86r5PJij+jCPcdMJ8CkAsthnepk3QiO8iuY7NS 25ZAgPiq3JixUxRKoJMOowpMVc9opE3ZwtGUr6foQOVWKVkfKxeLOP43uy5x2YUy3QxD /W/k6TmVQfFHegj87zwuYzcqRbnJUgy+lmuZfaoK7jES2+QNeTz7ZDrgpxSkFlD0m8Oa 02v42XThYL+EpsyncwXXbnQ3WD3Pa8oSRoKcU6az5JG0dWUGBgEIg1JWFLvSACzz/sUk j5+33GwuKF25q21u+xxwJiZuKo90lYNOg4H30BFDXpzATGYRi6hLf/cNOVprqaq+CyOP vEgg== 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=RhZZBkBqatZq0e22shFVaToDECPbFlUTcpcUxDYoIHA=; b=lvKuUDVaMEUVZIqd7xWac53gbMPnQNbNG8qUt3lrMUQUgKkHkmHznqpAFqV/boiB4N Be3pQdNoicUGOSiQv9/fWj3E1JVgwjWY5B0WON3/leqt4lb7+ShNg4p0l5DTTsgmPyaU cVh1KFIrSMmyqTjppdhTydS/hZnOwmwigpbWAcuUaSdqFslAlNZ47lM2GW9MvzKntvgh oB/o4c0uxrp4Z0K25u4YbnHrEClizJfW6BxYhFHJ3THsn5/OJeC4V9IDM/V3Uw8Mb5Ne rJVopC8wrVPIOpvJD0we7Eo8CJKsXgDMWzD0YBH4+rHsV9nR/BfJR3p1XMYv6B9859rA xLng== 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 b61-v6si3585592plc.500.2018.04.10.16.23.44; Tue, 10 Apr 2018 16:24:20 -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 S1755056AbeDJXS3 (ORCPT + 99 others); Tue, 10 Apr 2018 19:18:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40354 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754788AbeDJWbX (ORCPT ); Tue, 10 Apr 2018 18:31:23 -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 9BD03DE7; Tue, 10 Apr 2018 22:31:22 +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.15 124/168] net: dsa: Discard frames from unused ports Date: Wed, 11 Apr 2018 00:24:26 +0200 Message-Id: <20180410212805.848782700@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@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.15-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 @@ -117,6 +117,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; @@ -128,7 +129,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 */