From patchwork Tue Oct 27 13:49:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 312115 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 BAE50C4363A for ; Tue, 27 Oct 2020 17:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78A5321D24 for ; Tue, 27 Oct 2020 17:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603818855; bh=8PIeWVRx27BnySio/EKaVL5Jbwccp4QCuzh0j6WDt+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ybKfsEMIdSw26BDegclQf/FwfvUK0bIHP+g7RelvxNEFRqK7LMLIu40xgdM/QYvd+ 6Gsx1vvO7j0kGMSxcnLCMgamStP000PyG6IvB5QJECz6rcgBuJC8ebKMZ868Rn+JB8 UrrEzug87rjjUXGFUCs/YSK0nUJnbF4ed1M63Ig0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1817155AbgJ0RON (ORCPT ); Tue, 27 Oct 2020 13:14:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:60368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1784029AbgJ0O6v (ORCPT ); Tue, 27 Oct 2020 10:58:51 -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 25F1B20715; Tue, 27 Oct 2020 14:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810730; bh=8PIeWVRx27BnySio/EKaVL5Jbwccp4QCuzh0j6WDt+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S5uEr1ovRXvUamvOVfY4RESFEHEWyxUoTneub06sgQF8XLirIwygmXS52uzDho2Cv luEb/cUy75PpCg6n8YhuZTxejVsUp1Az5wINMmQwd24TlgZ5oNF4slBFt0lnU5AF4l 4sNkhz5TOWqbPfgAgk8H6T8MPgRq/5JbBEmFnsH8= 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 5.8 242/633] net: dsa: rtl8366: Check validity of passed VLANs Date: Tue, 27 Oct 2020 14:49:45 +0100 Message-Id: <20201027135534.027315147@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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 99cdb2f18fa2f..a62d76a048dfa 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);