diff options
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 16 |
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; |