Skip to contentSkip to conversation

openvswitch: Stricter validation for the userspace action

PATCH Applied Eelco Chaudron 4 participants 4 messages May 12, 2025 – May 15, 2025

Subsystems (3)
lore
Share & tools
lore

Eelco Chaudron

author maintainer
#0 lore raw

PATCH v2 1/1 openvswitch: Stricter validation for the userspace action

This change enhances the robustness of validate_userspace() by ensuring that all Netlink attributes are fully contained within the parent attribute. The previous use of nla_parse_nested_deprecated() could silently skip trailing or malformed attributes, as it stops parsing at the first invalid entry.

By switching to nla_parse_deprecated_strict(), we make sure only fully validated attributes are copied for later use.

---
v2: Changed commit message based on Ilya's feedback.

---
 net/openvswitch/flow_netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/flow_netlink.c +2 -1
index 518be23e48ea..ad64bb9ab5e2 100644
@@ -3049,7 +3049,8 @@ static int validate_userspace(const struct nlattr *attr)
 	struct nlattr *a[OVS_USERSPACE_ATTR_MAX + 1];
 	int error;
 
-	error = nla_parse_nested_deprecated(a, OVS_USERSPACE_ATTR_MAX, attr,
+	error = nla_parse_deprecated_strict(a, OVS_USERSPACE_ATTR_MAX,
+					    nla_data(attr), nla_len(attr),
 					    userspace_policy, NULL);
 	if (error)
 		return error;
Signature · 1 line
2.47.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Eelco Chaudron

This change enhances the robustness of validate_userspace() by ensuring that all Netlink attributes are fully contained within the parent attribute. The previous use of nla_parse_nested_deprecated() could silently skip trailing or malformed attributes, as it stops parsing at the first invalid entry.

Quoted 6 lines

By switching to nla_parse_deprecated_strict(), we make sure only fully validated attributes are copied for later use.

---
v2: Changed commit message based on Ilya's feedback.

maintainer Acked-by on v2 1/1
#2 lore raw
In reply to Eelco Chaudron
Quoted 8 lines · Eelco Chaudron

This change enhances the robustness of validate_userspace() by ensuring that all Netlink attributes are fully contained within the parent attribute. The previous use of nla_parse_nested_deprecated() could silently skip trailing or malformed attributes, as it stops parsing at the first invalid entry.

By switching to nla_parse_deprecated_strict(), we make sure only fully validated attributes are copied for later use.

Just to re-iterate for anyone reading this thread, copying non-validated attributes is not a problem as they will be ignored during execution.

The change looks fine to me, thanks!

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

Hello:

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

Quoted 10 lines · On Mon, 12 May 2025 10:08:24 +0200 you wrote:

This change enhances the robustness of validate_userspace() by ensuring that all Netlink attributes are fully contained within the parent attribute. The previous use of nla_parse_nested_deprecated() could silently skip trailing or malformed attributes, as it stops parsing at the first invalid entry.

By switching to nla_parse_deprecated_strict(), we make sure only fully validated attributes are copied for later use.

[...]

Here is the summary with links:
- [net-next,v2] openvswitch: Stricter validation for the userspace action

    https://git.kernel.org/netdev/net-next/c/88906f559541

You are awesome, thank you!

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