aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2013-09-01 11:39:52 -0400
committerRoland Dreier <roland@purestorage.com>2013-09-02 14:12:48 -0400
commit22878dbc9173a7f0322dd697b1b5b49a83a1d4d5 (patch)
treecfb2e55461d5893c65de39e3472e8f78264273c4 /drivers/infiniband/core
parentf77c0162a339400ad16f657603fdc3bf11654fd3 (diff)
IB/core: Better checking of userspace values for receive flow steering
- Don't allow unsupported comp_mask values, user should check ibv_query_device to know which features are supported. - Add a check in ib_uverbs_create_flow() to verify the size passed from the user space. Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 6e98df929e29..9112410da11d 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2652,17 +2652,31 @@ ssize_t ib_uverbs_create_flow(struct ib_uverbs_file *file,
2652 if (copy_from_user(&cmd, buf, sizeof(cmd))) 2652 if (copy_from_user(&cmd, buf, sizeof(cmd)))
2653 return -EFAULT; 2653 return -EFAULT;
2654 2654
2655 if (cmd.comp_mask)
2656 return -EINVAL;
2657
2655 if ((cmd.flow_attr.type == IB_FLOW_ATTR_SNIFFER && 2658 if ((cmd.flow_attr.type == IB_FLOW_ATTR_SNIFFER &&
2656 !capable(CAP_NET_ADMIN)) || !capable(CAP_NET_RAW)) 2659 !capable(CAP_NET_ADMIN)) || !capable(CAP_NET_RAW))
2657 return -EPERM; 2660 return -EPERM;
2658 2661
2662 if (cmd.flow_attr.num_of_specs < 0 ||
2663 cmd.flow_attr.num_of_specs > IB_FLOW_SPEC_SUPPORT_LAYERS)
2664 return -EINVAL;
2665
2666 kern_attr_size = cmd.flow_attr.size - sizeof(cmd) -
2667 sizeof(struct ib_uverbs_cmd_hdr_ex);
2668
2669 if (cmd.flow_attr.size < 0 || cmd.flow_attr.size > in_len ||
2670 kern_attr_size < 0 || kern_attr_size >
2671 (cmd.flow_attr.num_of_specs * sizeof(struct ib_kern_spec)))
2672 return -EINVAL;
2673
2659 if (cmd.flow_attr.num_of_specs) { 2674 if (cmd.flow_attr.num_of_specs) {
2660 kern_flow_attr = kmalloc(cmd.flow_attr.size, GFP_KERNEL); 2675 kern_flow_attr = kmalloc(cmd.flow_attr.size, GFP_KERNEL);
2661 if (!kern_flow_attr) 2676 if (!kern_flow_attr)
2662 return -ENOMEM; 2677 return -ENOMEM;
2663 2678
2664 memcpy(kern_flow_attr, &cmd.flow_attr, sizeof(*kern_flow_attr)); 2679 memcpy(kern_flow_attr, &cmd.flow_attr, sizeof(*kern_flow_attr));
2665 kern_attr_size = cmd.flow_attr.size - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr_ex);
2666 if (copy_from_user(kern_flow_attr + 1, buf + sizeof(cmd), 2680 if (copy_from_user(kern_flow_attr + 1, buf + sizeof(cmd),
2667 kern_attr_size)) { 2681 kern_attr_size)) {
2668 err = -EFAULT; 2682 err = -EFAULT;