Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp221674pxx; Wed, 28 Oct 2020 03:15:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5nP28FrUg9zrF80js3jr8PfXTwP74xyKQKT9H44XhAoSFx08tX1O8K/zJ0k25T3Ah4Ys2 X-Received: by 2002:a05:6402:1119:: with SMTP id u25mr7208173edv.37.1603880118553; Wed, 28 Oct 2020 03:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603880118; cv=none; d=google.com; s=arc-20160816; b=xY2QLEit+mrmzLzlpLywLzwmwP8cjU/tnBZ6kjhVbpyYKuWT+PGrFyUhe2mVYNhhSF lVjyt94NbSjpOQvQZgzYh0zjQ9v/lKJ0si4BpPQlqKQ7qQH5qkEafjIaOqn98x1pM/5N 4oXCAbn6B2iUn4lQPU9x54zg3YMYi5TNd9p/cbQpLR+58gLRzr4MVeBnGMv3InmSt9fW hb949kjeOyj5CW1aPi6NVtOrrDaueN0obF1cAIj/UVpdwM34KZN12Neii0bxnTlKXukj rt7yd+snQHQMWHdFEoFolwS4rZfr3/7PHBlscVzEjU4ZpKTfPPfandgSp+19siPsTFaX psTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uF7Mb77Ng3Sx6zEbIJLkPq8r1UQS6N+CwTaf0fW8qnc=; b=Cm8vz51Z7t1UDZzD+gloomG865HSXWi13P3lj4SNzbHeojZnwBno6kxI6bPVWAMoyY 0+Qv5tMIT3qZV3iRABL16kW+F+mWNfCJs8aHJwbpEKcsikqMZJrx1X6ZFJxqzv68Eh2U oX7U8CmWABAd8dZ4aO8n7+onyDGp4N5GT464QzKcx+6WHj+9rUgXKHyU00FXUnsZE0Xh we6I0V6IigI+QtzqLJmSnUUvme9SXZyQlOuDf1DhdwZbpxFyul4Kzv12OsTevHxy/g2o uhx0n5LxfbbJU90o61m0s0QI5BMBFb/mCY3wf2N/7gAQ6y+ReAwFErSf49zO/S051zy0 oRDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ClObZaO4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si2953320edn.245.2020.10.28.03.14.56; Wed, 28 Oct 2020 03:15:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ClObZaO4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760882AbgJ0Ogz (ORCPT + 99 others); Tue, 27 Oct 2020 10:36:55 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.25.1