openvswitch: Stricter validation for the userspace action
authorEelco Chaudron <echaudro@redhat.com>
Mon, 12 May 2025 08:08:24 +0000 (10:08 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 15 May 2025 02:13:34 +0000 (19:13 -0700)
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 <echaudro@redhat.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Link: https://patch.msgid.link/67eb414e2d250e8408bb8afeb982deca2ff2b10b.1747037304.git.echaudro@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/openvswitch/flow_netlink.c

index 518be23e48ea934d77dbc129d7be6c9a52f9702d..ad64bb9ab5e256dfd9d504b1d9e8b3b93549e0b6 100644 (file)
@@ -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;