RDMA/ucma: Limit possible option size
[pandora-kernel.git] / drivers / infiniband / core / ucma.c
index 91e82b7..79d0333 100644 (file)
@@ -1000,6 +1000,9 @@ static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf,
        if (IS_ERR(ctx))
                return PTR_ERR(ctx);
 
+       if (unlikely(cmd.optval > KMALLOC_MAX_SIZE))
+               return -EINVAL;
+
        optval = kmalloc(cmd.optlen, GFP_KERNEL);
        if (!optval) {
                ret = -ENOMEM;