* [PATCH net v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING
@ 2024-01-18 13:03 Lin Ma
2024-01-19 15:44 ` Simon Horman
2024-01-20 5:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Lin Ma @ 2024-01-18 13:03 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, linma, netdev, linux-kernel
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 <linma@zju.edu.cn>
---
V1 -> V2: make net-next to net as suggested by Paolo
and add Fixes tag for this one
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 214532173536..a3b68243fd4b 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.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING
2024-01-18 13:03 [PATCH net v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING Lin Ma
@ 2024-01-19 15:44 ` Simon Horman
2024-01-20 5:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-01-19 15:44 UTC (permalink / raw)
To: Lin Ma; +Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel
On Thu, Jan 18, 2024 at 09:03:06PM +0800, Lin Ma wrote:
> 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 <linma@zju.edu.cn>
> ---
> V1 -> V2: make net-next to net as suggested by Paolo
> and add Fixes tag for this one
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING
2024-01-18 13:03 [PATCH net v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING Lin Ma
2024-01-19 15:44 ` Simon Horman
@ 2024-01-20 5:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-20 5:30 UTC (permalink / raw)
To: Lin Ma; +Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 18 Jan 2024 21:03:06 +0800 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [net,v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING
https://git.kernel.org/netdev/net/c/6c21660fe221
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-20 5:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18 13:03 [PATCH net v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING Lin Ma
2024-01-19 15:44 ` Simon Horman
2024-01-20 5:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).