Skip to contentSkip to conversation

net: openvswitch: fix nested key length validation in the set() action

PATCH Applied Ilya Maximets 4 participants 4 messages Apr 12, 2025 – Apr 14, 2025

Subsystems (3)
lore
Share & tools
lore

Ilya Maximets

author maintainer
#0 lore raw

PATCH 1/1 net: openvswitch: fix nested key length validation in the set() action

It's not safe to access nla_len(ovs_key) if the data is smaller than the netlink header. Check that the attribute is OK first.

Fixes ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Reported-by [email protected]
---
 net/openvswitch/flow_netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/flow_netlink.c +2 -1
index 95e0dd14dc1a..518be23e48ea 100644
@@ -2876,7 +2876,8 @@ static int validate_set(const struct nlattr *a,
 	size_t key_len;
 
 	/* There can be only one key in a action */
-	if (nla_total_size(nla_len(ovs_key)) != nla_len(a))
+	if (!nla_ok(ovs_key, nla_len(a)) ||
+	    nla_total_size(nla_len(ovs_key)) != nla_len(a))
 		return -EINVAL;
 
 	key_len = nla_len(ovs_key);
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Ilya Maximets

It's not safe to access nla_len(ovs_key) if the data is smaller than the netlink header. Check that the attribute is OK first.

Fixes ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Reported-by [email protected]

The patch looks good to me.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Ilya Maximets
Quoted 9 lines · Ilya Maximets

It's not safe to access nla_len(ovs_key) if the data is smaller than the netlink header. Check that the attribute is OK first.

Fixes ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Reported-by [email protected]

---

#3 lore raw
In reply to Ilya Maximets
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Sat, 12 Apr 2025 12:40:18 +0200 you wrote:

It's not safe to access nla_len(ovs_key) if the data is smaller than the netlink header. Check that the attribute is OK first.

Fixes ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Reported-by [email protected]

[...]

Here is the summary with links:
- [net] net: openvswitch: fix nested key length validation in the set() action

    https://git.kernel.org/netdev/net/c/65d91192aa66

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html