Skip to content

Commit 0cadb4d

Browse files
EdwardSrorleon
authored andcommitted
RDMA/uverbs: Restrict usage of privileged QKEYs
According to the IB specification rel-1.6, section 3.5.3: "QKEYs with the most significant bit set are considered controlled QKEYs, and a HCA does not allow a consumer to arbitrarily specify a controlled QKEY." Thus, block non-privileged users from setting such a QKEY. Cc: stable@vger.kernel.org Fixes: bc38a6a ("[PATCH] IB uverbs: core implementation") Signed-off-by: Edward Srouji <edwards@nvidia.com> Link: https://lore.kernel.org/r/c00c809ddafaaf87d6f6cb827978670989a511b3.1685960567.git.leon@kernel.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 58030c7 commit 0cadb4d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,8 +1850,13 @@ static int modify_qp(struct uverbs_attr_bundle *attrs,
18501850
attr->path_mtu = cmd->base.path_mtu;
18511851
if (cmd->base.attr_mask & IB_QP_PATH_MIG_STATE)
18521852
attr->path_mig_state = cmd->base.path_mig_state;
1853-
if (cmd->base.attr_mask & IB_QP_QKEY)
1853+
if (cmd->base.attr_mask & IB_QP_QKEY) {
1854+
if (cmd->base.qkey & IB_QP_SET_QKEY && !capable(CAP_NET_RAW)) {
1855+
ret = -EPERM;
1856+
goto release_qp;
1857+
}
18541858
attr->qkey = cmd->base.qkey;
1859+
}
18551860
if (cmd->base.attr_mask & IB_QP_RQ_PSN)
18561861
attr->rq_psn = cmd->base.rq_psn;
18571862
if (cmd->base.attr_mask & IB_QP_SQ_PSN)

0 commit comments

Comments
 (0)