From patchwork Tue Oct 27 13:52:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 312969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15009C55179 for ; Tue, 27 Oct 2020 14:21:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1972207BB for ; Tue, 27 Oct 2020 14:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808468; bh=kAIq855fC74ZltoAnwvgBoKJnImRxtTXpUe4V7emtII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=X4JE8Xzd5lsFvCQkIChR6qX6fSJ4j030Nm6Ko5Jf0RNvylUqazrhKXTfptuRqoIzq 3dkVNyY4jQHpOLdAQIXAU7MTTaowjsyWmWdQzQDx5Bakt7PmO6GCf0O3WZ1RXISYXY ACpW66nhsUNmW2avPiG29V6h7tnxRNiJwO7fS7Qg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2901184AbgJ0OVG (ORCPT ); Tue, 27 Oct 2020 10:21:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:45150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2901169AbgJ0OU4 (ORCPT ); Tue, 27 Oct 2020 10:20:56 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 F2BF6206D4; Tue, 27 Oct 2020 14:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808456; bh=kAIq855fC74ZltoAnwvgBoKJnImRxtTXpUe4V7emtII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1F5rGN1N5DFt4I4R0aFZec44bt3Hj8j1DqToWWmjbTlZPa3fB4YttqgCgbN85DXG JW7Q7oQtl1P5d0tlK4NyP9oGyyyp2Vxx80NrxhAjybyH4bRx1UoAx1rjDE71lAwqqf 4fxBRVrMr+PD6oacELeDdnK4Y4YgiGwhwIpvQXu8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Linus Walleij , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 098/264] net: dsa: rtl8366: Check validity of passed VLANs Date: Tue, 27 Oct 2020 14:52:36 +0100 Message-Id: <20201027135435.299288528@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135430.632029009@linuxfoundation.org> References: <20201027135430.632029009@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Linus Walleij [ Upstream commit 6641a2c42b0a307b7638d10e5d4b90debc61389d ] The rtl8366_set_vlan() and rtl8366_set_pvid() get invalid VLANs tossed at it, especially VLAN0, something the hardware and driver cannot handle. Check validity and bail out like we do in the other callbacks. Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/rtl8366.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 430988f797225..c854fea473f76 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -43,6 +43,9 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member, int ret; int i; + if (!smi->ops->is_vlan_valid(smi, vid)) + return -EINVAL; + dev_dbg(smi->dev, "setting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n", vid, member, untag); @@ -118,6 +121,9 @@ int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port, int ret; int i; + if (!smi->ops->is_vlan_valid(smi, vid)) + return -EINVAL; + /* Try to find an existing MC entry for this VID */ for (i = 0; i < smi->num_vlan_mc; i++) { ret = smi->ops->get_vlan_mc(smi, i, &vlanmc);