|
@@ -632,6 +632,9 @@ static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf,
|
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
|
|
+ if (!rdma_addr_size_in6(&cmd.addr))
|
|
|
|
|
+ return -EINVAL;
|
|
|
|
|
+
|
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
|
if (IS_ERR(ctx))
|
|
if (IS_ERR(ctx))
|
|
|
return PTR_ERR(ctx);
|
|
return PTR_ERR(ctx);
|
|
@@ -645,22 +648,21 @@ static ssize_t ucma_bind(struct ucma_file *file, const char __user *inbuf,
|
|
|
int in_len, int out_len)
|
|
int in_len, int out_len)
|
|
|
{
|
|
{
|
|
|
struct rdma_ucm_bind cmd;
|
|
struct rdma_ucm_bind cmd;
|
|
|
- struct sockaddr *addr;
|
|
|
|
|
struct ucma_context *ctx;
|
|
struct ucma_context *ctx;
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
- addr = (struct sockaddr *) &cmd.addr;
|
|
|
|
|
- if (cmd.reserved || !cmd.addr_size || (cmd.addr_size != rdma_addr_size(addr)))
|
|
|
|
|
|
|
+ if (cmd.reserved || !cmd.addr_size ||
|
|
|
|
|
+ cmd.addr_size != rdma_addr_size_kss(&cmd.addr))
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
|
if (IS_ERR(ctx))
|
|
if (IS_ERR(ctx))
|
|
|
return PTR_ERR(ctx);
|
|
return PTR_ERR(ctx);
|
|
|
|
|
|
|
|
- ret = rdma_bind_addr(ctx->cm_id, addr);
|
|
|
|
|
|
|
+ ret = rdma_bind_addr(ctx->cm_id, (struct sockaddr *) &cmd.addr);
|
|
|
ucma_put_ctx(ctx);
|
|
ucma_put_ctx(ctx);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
@@ -670,23 +672,22 @@ static ssize_t ucma_resolve_ip(struct ucma_file *file,
|
|
|
int in_len, int out_len)
|
|
int in_len, int out_len)
|
|
|
{
|
|
{
|
|
|
struct rdma_ucm_resolve_ip cmd;
|
|
struct rdma_ucm_resolve_ip cmd;
|
|
|
- struct sockaddr *src, *dst;
|
|
|
|
|
struct ucma_context *ctx;
|
|
struct ucma_context *ctx;
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
- src = (struct sockaddr *) &cmd.src_addr;
|
|
|
|
|
- dst = (struct sockaddr *) &cmd.dst_addr;
|
|
|
|
|
- if (!rdma_addr_size(src) || !rdma_addr_size(dst))
|
|
|
|
|
|
|
+ if (!rdma_addr_size_in6(&cmd.src_addr) ||
|
|
|
|
|
+ !rdma_addr_size_in6(&cmd.dst_addr))
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
|
if (IS_ERR(ctx))
|
|
if (IS_ERR(ctx))
|
|
|
return PTR_ERR(ctx);
|
|
return PTR_ERR(ctx);
|
|
|
|
|
|
|
|
- ret = rdma_resolve_addr(ctx->cm_id, src, dst, cmd.timeout_ms);
|
|
|
|
|
|
|
+ ret = rdma_resolve_addr(ctx->cm_id, (struct sockaddr *) &cmd.src_addr,
|
|
|
|
|
+ (struct sockaddr *) &cmd.dst_addr, cmd.timeout_ms);
|
|
|
ucma_put_ctx(ctx);
|
|
ucma_put_ctx(ctx);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
@@ -696,24 +697,23 @@ static ssize_t ucma_resolve_addr(struct ucma_file *file,
|
|
|
int in_len, int out_len)
|
|
int in_len, int out_len)
|
|
|
{
|
|
{
|
|
|
struct rdma_ucm_resolve_addr cmd;
|
|
struct rdma_ucm_resolve_addr cmd;
|
|
|
- struct sockaddr *src, *dst;
|
|
|
|
|
struct ucma_context *ctx;
|
|
struct ucma_context *ctx;
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
- src = (struct sockaddr *) &cmd.src_addr;
|
|
|
|
|
- dst = (struct sockaddr *) &cmd.dst_addr;
|
|
|
|
|
- if (cmd.reserved || (cmd.src_size && (cmd.src_size != rdma_addr_size(src))) ||
|
|
|
|
|
- !cmd.dst_size || (cmd.dst_size != rdma_addr_size(dst)))
|
|
|
|
|
|
|
+ if (cmd.reserved ||
|
|
|
|
|
+ (cmd.src_size && (cmd.src_size != rdma_addr_size_kss(&cmd.src_addr))) ||
|
|
|
|
|
+ !cmd.dst_size || (cmd.dst_size != rdma_addr_size_kss(&cmd.dst_addr)))
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
ctx = ucma_get_ctx(file, cmd.id);
|
|
|
if (IS_ERR(ctx))
|
|
if (IS_ERR(ctx))
|
|
|
return PTR_ERR(ctx);
|
|
return PTR_ERR(ctx);
|
|
|
|
|
|
|
|
- ret = rdma_resolve_addr(ctx->cm_id, src, dst, cmd.timeout_ms);
|
|
|
|
|
|
|
+ ret = rdma_resolve_addr(ctx->cm_id, (struct sockaddr *) &cmd.src_addr,
|
|
|
|
|
+ (struct sockaddr *) &cmd.dst_addr, cmd.timeout_ms);
|
|
|
ucma_put_ctx(ctx);
|
|
ucma_put_ctx(ctx);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
@@ -1166,6 +1166,11 @@ static ssize_t ucma_init_qp_attr(struct ucma_file *file,
|
|
|
if (IS_ERR(ctx))
|
|
if (IS_ERR(ctx))
|
|
|
return PTR_ERR(ctx);
|
|
return PTR_ERR(ctx);
|
|
|
|
|
|
|
|
|
|
+ if (!ctx->cm_id->device) {
|
|
|
|
|
+ ret = -EINVAL;
|
|
|
|
|
+ goto out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
resp.qp_attr_mask = 0;
|
|
resp.qp_attr_mask = 0;
|
|
|
memset(&qp_attr, 0, sizeof qp_attr);
|
|
memset(&qp_attr, 0, sizeof qp_attr);
|
|
|
qp_attr.qp_state = cmd.qp_state;
|
|
qp_attr.qp_state = cmd.qp_state;
|
|
@@ -1307,7 +1312,7 @@ static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf,
|
|
|
if (IS_ERR(ctx))
|
|
if (IS_ERR(ctx))
|
|
|
return PTR_ERR(ctx);
|
|
return PTR_ERR(ctx);
|
|
|
|
|
|
|
|
- if (unlikely(cmd.optval > KMALLOC_MAX_SIZE))
|
|
|
|
|
|
|
+ if (unlikely(cmd.optlen > KMALLOC_MAX_SIZE))
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
optval = memdup_user((void __user *) (unsigned long) cmd.optval,
|
|
optval = memdup_user((void __user *) (unsigned long) cmd.optval,
|
|
@@ -1331,7 +1336,7 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
|
|
|
{
|
|
{
|
|
|
struct rdma_ucm_notify cmd;
|
|
struct rdma_ucm_notify cmd;
|
|
|
struct ucma_context *ctx;
|
|
struct ucma_context *ctx;
|
|
|
- int ret;
|
|
|
|
|
|
|
+ int ret = -EINVAL;
|
|
|
|
|
|
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
@@ -1340,7 +1345,9 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
|
|
|
if (IS_ERR(ctx))
|
|
if (IS_ERR(ctx))
|
|
|
return PTR_ERR(ctx);
|
|
return PTR_ERR(ctx);
|
|
|
|
|
|
|
|
- ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
|
|
|
|
|
|
|
+ if (ctx->cm_id->device)
|
|
|
|
|
+ ret = rdma_notify(ctx->cm_id, (enum ib_event_type)cmd.event);
|
|
|
|
|
+
|
|
|
ucma_put_ctx(ctx);
|
|
ucma_put_ctx(ctx);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
@@ -1426,7 +1433,7 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
|
|
|
join_cmd.response = cmd.response;
|
|
join_cmd.response = cmd.response;
|
|
|
join_cmd.uid = cmd.uid;
|
|
join_cmd.uid = cmd.uid;
|
|
|
join_cmd.id = cmd.id;
|
|
join_cmd.id = cmd.id;
|
|
|
- join_cmd.addr_size = rdma_addr_size((struct sockaddr *) &cmd.addr);
|
|
|
|
|
|
|
+ join_cmd.addr_size = rdma_addr_size_in6(&cmd.addr);
|
|
|
if (!join_cmd.addr_size)
|
|
if (!join_cmd.addr_size)
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
@@ -1445,7 +1452,7 @@ static ssize_t ucma_join_multicast(struct ucma_file *file,
|
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
- if (!rdma_addr_size((struct sockaddr *)&cmd.addr))
|
|
|
|
|
|
|
+ if (!rdma_addr_size_kss(&cmd.addr))
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return ucma_process_join(file, &cmd, out_len);
|
|
return ucma_process_join(file, &cmd, out_len);
|