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.

Signed-off-by: Eelco Chaudron <echau...@redhat.com>
---
v2: Changed commit message based on Ilya's feedback.
---
 net/openvswitch/flow_netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 518be23e48ea..ad64bb9ab5e2 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -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;
-- 
2.47.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to