datapath: Correctly validate vport attributes on old kernels.
authorJesse Gross <jesse@nicira.com>
Tue, 20 Sep 2011 17:31:29 +0000 (10:31 -0700)
committerJesse Gross <jesse@nicira.com>
Tue, 20 Sep 2011 22:21:06 +0000 (15:21 -0700)
The vport policy for OVS_VPORT_ATTR_PORT_NO and OVS_VPORT_ATTR_TYPE
are present only in the section for newer kernels.  This means that
on older kernels the length of these attributes are never checked
anywhere but we go ahead and read from them anyways.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/datapath.c

index 5bc0cc9..668d2ff 100644 (file)
@@ -1619,14 +1619,14 @@ static struct genl_ops dp_datapath_genl_ops[] = {
 static const struct nla_policy vport_policy[ODP_VPORT_ATTR_MAX + 1] = {
 #ifdef HAVE_NLA_NUL_STRING
        [ODP_VPORT_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
-       [ODP_VPORT_ATTR_PORT_NO] = { .type = NLA_U32 },
-       [ODP_VPORT_ATTR_TYPE] = { .type = NLA_U32 },
        [ODP_VPORT_ATTR_STATS] = { .len = sizeof(struct rtnl_link_stats64) },
        [ODP_VPORT_ATTR_ADDRESS] = { .len = ETH_ALEN },
 #else
        [ODP_VPORT_ATTR_STATS] = { .minlen = sizeof(struct rtnl_link_stats64) },
        [ODP_VPORT_ATTR_ADDRESS] = { .minlen = ETH_ALEN },
 #endif
+       [ODP_VPORT_ATTR_PORT_NO] = { .type = NLA_U32 },
+       [ODP_VPORT_ATTR_TYPE] = { .type = NLA_U32 },
        [ODP_VPORT_ATTR_MTU] = { .type = NLA_U32 },
        [ODP_VPORT_ATTR_OPTIONS] = { .type = NLA_NESTED },
 };