From 6d7568dc38fb832b7e152c184b0bdfdca6bb9527 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 10 May 2010 13:53:26 -0700 Subject: [PATCH] datapath: Avoid possibility of negative 'n_flows' in struct odp_flowvec. do_flowvec_ioctl() was checking for too-big 'n_flows' but not negative 'n_flows'. We could add that check too, but 'n_flows' should never be negative so it's better to just use an unsigned type. --- datapath/datapath.c | 7 ++++--- include/openvswitch/datapath-protocol.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index 79a1f6325..eec998ca4 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -1143,7 +1143,8 @@ error: static int query_flows(struct datapath *dp, const struct odp_flowvec *flowvec) { struct tbl *table = rcu_dereference(dp->table); - int i; + u32 i; + for (i = 0; i < flowvec->n_flows; i++) { struct __user odp_flow *ufp = &flowvec->flows[i]; struct odp_flow uf; @@ -1167,8 +1168,8 @@ static int query_flows(struct datapath *dp, const struct odp_flowvec *flowvec) struct list_flows_cbdata { struct odp_flow __user *uflows; - int n_flows; - int listed_flows; + u32 n_flows; + u32 listed_flows; }; static int list_flow(struct tbl_node *node, void *cbdata_) diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index 94723ef05..1c2dba9b5 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -242,7 +242,7 @@ struct odp_flow_put { struct odp_flowvec { struct odp_flow *flows; - int n_flows; + __u32 n_flows; }; /* The VLAN id is 12 bits, so we can use the entire 16 bits to indicate -- 2.43.0