Skip to content

Commit

Permalink
RDMA/uverbs: Properly check command supported mask
Browse files Browse the repository at this point in the history
The check based on index is not sufficient because

  IB_USER_VERBS_EX_CMD_CREATE_CQ = IB_USER_VERBS_CMD_CREATE_CQ

and IB_USER_VERBS_CMD_CREATE_CQ <= IB_USER_VERBS_CMD_OPEN_QP,
so if we execute IB_USER_VERBS_EX_CMD_CREATE_CQ this code checks
ib_dev->uverbs_cmd_mask not ib_dev->uverbs_ex_cmd_mask.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Leon Romanovsky authored and Doug Ledford committed Feb 23, 2018
1 parent 77833b8 commit eb455e3
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,19 +635,13 @@ struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file
return filp;
}

static bool verify_command_mask(struct ib_device *ib_dev, __u32 command)
static bool verify_command_mask(struct ib_device *ib_dev,
__u32 command, bool extended)
{
u64 mask;
if (!extended)
return ib_dev->uverbs_cmd_mask & BIT_ULL(command);

if (command <= IB_USER_VERBS_CMD_OPEN_QP)
mask = ib_dev->uverbs_cmd_mask;
else
mask = ib_dev->uverbs_ex_cmd_mask;

if (mask & ((u64)1 << command))
return true;

return false;
return ib_dev->uverbs_ex_cmd_mask & BIT_ULL(command);
}

static bool verify_command_idx(u32 command, bool extended)
Expand Down Expand Up @@ -722,7 +716,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
goto out;
}

if (!verify_command_mask(ib_dev, command)) {
if (!verify_command_mask(ib_dev, command, extended)) {
ret = -EOPNOTSUPP;
goto out;
}
Expand Down

0 comments on commit eb455e3

Please sign in to comment.