From patchwork Tue Oct 27 13:51:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307087 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=unavailable 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 CE219C56201 for ; Tue, 27 Oct 2020 17:35:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 813C320878 for ; Tue, 27 Oct 2020 17:35:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603820151; bh=8PIeWVRx27BnySio/EKaVL5Jbwccp4QCuzh0j6WDt+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Wux8pJmC5OTYh4rXIv1hUPPVt9Rehwd89dOIZa/QKXGxGRZof6MTmBytI+EvPFM9a lbwzf/VJqx5ZXaGwN8Z7LSzPScnxsKuaRJkBUgcKNsAHfKb8ODb3tBKHtJqrtUZXNr FsFoTqG/Fu1VoJTE+4qZc+llkJtWUJYw6IAGJRZE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760850AbgJ0Ogq (ORCPT ); Tue, 27 Oct 2020 10:36:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:35626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760843AbgJ0Ogn (ORCPT ); Tue, 27 Oct 2020 10:36:43 -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 C6E7E207BB; Tue, 27 Oct 2020 14:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809403; bh=8PIeWVRx27BnySio/EKaVL5Jbwccp4QCuzh0j6WDt+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ClObZaO4lV5Vh2iY/skqXNfV6uB8Ebgsla5kpk+nh1ZPt5MIZRzWpHOGkO+Tmn+0F Fo/DgKC+4v5tcrI37QjCMQYxPYJE2aPg8A6AR0JeM8Zf4puxOs6L5ldEXwTgK5hrGz i8gKWsIj8JCo4W78RyWdULpCQfSHvgUjMBFLUWCc= 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.4 152/408] net: dsa: rtl8366: Check validity of passed VLANs Date: Tue, 27 Oct 2020 14:51:30 +0100 Message-Id: <20201027135502.149840847@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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);