Skip to content

Commit 6c21660

Browse files
f0rm2l1nkuba-moo
authored andcommitted
vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING
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: 07b5b17 ("[VLAN]: Use rtnl_link API") Signed-off-by: Lin Ma <linma@zju.edu.cn> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/20240118130306.1644001-1-linma@zju.edu.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9b69795 commit 6c21660

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/8021q/vlan_netlink.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,16 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[],
118118
}
119119
if (data[IFLA_VLAN_INGRESS_QOS]) {
120120
nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) {
121+
if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING)
122+
continue;
121123
m = nla_data(attr);
122124
vlan_dev_set_ingress_priority(dev, m->to, m->from);
123125
}
124126
}
125127
if (data[IFLA_VLAN_EGRESS_QOS]) {
126128
nla_for_each_nested(attr, data[IFLA_VLAN_EGRESS_QOS], rem) {
129+
if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING)
130+
continue;
127131
m = nla_data(attr);
128132
err = vlan_dev_set_egress_priority(dev, m->from, m->to);
129133
if (err)

0 commit comments

Comments
 (0)