openvswitch: Stricter validation for the userspace action
Subsystems (3)
Eelco Chaudron
maintainerPATCH 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
@@ -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
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 ofnla_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.Signed-off-by Eelco Chaudron <[email protected]>---
v2: Changed commit message based on Ilya's feedback.
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 ofnla_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!
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 ofnla_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