From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C16097BB10; Wed, 21 Feb 2024 13:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708523744; cv=none; b=adpXl4XA0TRJ3HJmthVGORHCDgTnRQ2kmnLFkutQu1NZbzvwSYuIqjQ3xKoO/JBLm2br0lySh0M05WWP8ZYUFPwo7NPt/aSl3CuwT2969EylpSoPJbwrjiW9JfUT3JcaTn94dKKMrQvZmvzGXZgJ37a1WspSgWomGY9Ir3bwXNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708523744; c=relaxed/simple; bh=x8dH9IAqoyq/5gUcg3UYfZenAPH/y3uyoZtJTEzD7tg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G7MOo4KDiDzpP/YD5DXFljhEBUUks3xqag/Fe+Af9k/9yqi4dWIur6rOnW880GbjwQpO/nri6CQINl+EEKfk8HaihKbJnqviaVJ6EmzB62ylMIHomc8CneNU0dZUa/uEjrbTpg796SvtQBP+Sfo2VaoIKpReZBp/V4lGtFIRLJE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CdkOwIwe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CdkOwIwe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32A7FC433C7; Wed, 21 Feb 2024 13:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708523744; bh=x8dH9IAqoyq/5gUcg3UYfZenAPH/y3uyoZtJTEzD7tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CdkOwIwehubGLdWzlIBfbr6DN5HOy0zgaDfG+gtxo0w2hOmkmK0OlOe1AANM9rhM4 G8q/b83Yk6BX3dPE1IooKVGvbfr/gq4svtuBoSSJJgT+gh4RoZymKC4h41IOgB/Obb d9yHUbJ4muxQXPca1V43n0p7U7bkCwldDuhp82/o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lin Ma , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 045/379] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING Date: Wed, 21 Feb 2024 14:03:44 +0100 Message-ID: <20240221125956.250648160@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221125954.917878865@linuxfoundation.org> References: <20240221125954.917878865@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lin Ma [ Upstream commit 6c21660fe221a15c789dee2bc2fd95516bc5aeaf ] In the vlan_changelink function, a loop is used to parse the nested attributes IFLA_VLAN_EGRESS_QOS and IFLA_VLAN_INGRESS_QOS in order to obtain the struct ifla_vlan_qos_mapping. These two nested attributes are checked in the vlan_validate_qos_map function, which calls nla_validate_nested_deprecated with the vlan_map_policy. However, this deprecated validator applies a LIBERAL strictness, allowing the presence of an attribute with the type IFLA_VLAN_QOS_UNSPEC. Consequently, the loop in vlan_changelink may parse an attribute of type IFLA_VLAN_QOS_UNSPEC and believe it carries a payload of struct ifla_vlan_qos_mapping, which is not necessarily true. To address this issue and ensure compatibility, this patch introduces two type checks that skip attributes whose type is not IFLA_VLAN_QOS_MAPPING. Fixes: 07b5b17e157b ("[VLAN]: Use rtnl_link API") Signed-off-by: Lin Ma Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20240118130306.1644001-1-linma@zju.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/8021q/vlan_netlink.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c index 0db85aeb119b..99b277775257 100644 --- a/net/8021q/vlan_netlink.c +++ b/net/8021q/vlan_netlink.c @@ -118,12 +118,16 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[], } if (data[IFLA_VLAN_INGRESS_QOS]) { nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) { + if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING) + continue; m = nla_data(attr); vlan_dev_set_ingress_priority(dev, m->to, m->from); } } if (data[IFLA_VLAN_EGRESS_QOS]) { nla_for_each_nested(attr, data[IFLA_VLAN_EGRESS_QOS], rem) { + if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING) + continue; m = nla_data(attr); err = vlan_dev_set_egress_priority(dev, m->from, m->to); if (err) -- 2.43.0