Check for a cm_id->device in all user calls that need it in ibcore.
This was done by auditing all callers of ucma_get_ctx and switching the ones that unconditionally touch ->device to ucma_get_ctx_dev. This covers a little less than half of the call sites. The 11 remaining call sites to ucma_get_ctx() were manually audited. Linux commit: 4b658d1bbc16605330694bb3ef2570c465ef383d 8b77586bd8fe600d97f922c79f7222c46f37c118 MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
89a0812fa6
commit
41decb450f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336379
@ -151,6 +151,23 @@ static void ucma_put_ctx(struct ucma_context *ctx)
|
||||
complete(&ctx->comp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Same as ucm_get_ctx but requires that ->cm_id->device is valid, eg that the
|
||||
* CM_ID is bound.
|
||||
*/
|
||||
static struct ucma_context *ucma_get_ctx_dev(struct ucma_file *file, int id)
|
||||
{
|
||||
struct ucma_context *ctx = ucma_get_ctx(file, id);
|
||||
|
||||
if (IS_ERR(ctx))
|
||||
return ctx;
|
||||
if (!ctx->cm_id->device) {
|
||||
ucma_put_ctx(ctx);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void ucma_close_event_id(struct work_struct *work)
|
||||
{
|
||||
struct ucma_event *uevent_close = container_of(work, struct ucma_event, close_work);
|
||||
@ -712,7 +729,7 @@ static ssize_t ucma_resolve_route(struct ucma_file *file,
|
||||
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
||||
return -EFAULT;
|
||||
|
||||
ctx = ucma_get_ctx(file, cmd.id);
|
||||
ctx = ucma_get_ctx_dev(file, cmd.id);
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
@ -1020,7 +1037,7 @@ static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf,
|
||||
if (!cmd.conn_param.valid)
|
||||
return -EINVAL;
|
||||
|
||||
ctx = ucma_get_ctx(file, cmd.id);
|
||||
ctx = ucma_get_ctx_dev(file, cmd.id);
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
@ -1062,7 +1079,7 @@ static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
|
||||
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
||||
return -EFAULT;
|
||||
|
||||
ctx = ucma_get_ctx(file, cmd.id);
|
||||
ctx = ucma_get_ctx_dev(file, cmd.id);
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
@ -1090,7 +1107,7 @@ static ssize_t ucma_reject(struct ucma_file *file, const char __user *inbuf,
|
||||
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
||||
return -EFAULT;
|
||||
|
||||
ctx = ucma_get_ctx(file, cmd.id);
|
||||
ctx = ucma_get_ctx_dev(file, cmd.id);
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
@ -1109,7 +1126,7 @@ static ssize_t ucma_disconnect(struct ucma_file *file, const char __user *inbuf,
|
||||
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
||||
return -EFAULT;
|
||||
|
||||
ctx = ucma_get_ctx(file, cmd.id);
|
||||
ctx = ucma_get_ctx_dev(file, cmd.id);
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
@ -1134,7 +1151,7 @@ static ssize_t ucma_init_qp_attr(struct ucma_file *file,
|
||||
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
|
||||
return -EFAULT;
|
||||
|
||||
ctx = ucma_get_ctx(file, cmd.id);
|
||||
ctx = ucma_get_ctx_dev(file, cmd.id);
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
@ -1329,7 +1346,7 @@ static ssize_t ucma_process_join(struct ucma_file *file,
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
ctx = ucma_get_ctx(file, cmd->id);
|
||||
ctx = ucma_get_ctx_dev(file, cmd->id);
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user