Commit c8b32408 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Doug Ledford

RDMA/counters: Properly implement PID checks

"Auto" configuration mode is called for visible in that PID
namespace and it ensures that all counters and QPs are coexist
in the same namespace and belong to same PID.

Fixes: 99fa331d ("RDMA/counter: Add "auto" configuration mode support")
Reviewed-by: default avatarMark Zhang <markz@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Link: https://lore.kernel.org/r/20190815083834.9245-3-leon@kernel.orgSigned-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 948a7287
...@@ -149,13 +149,11 @@ static bool auto_mode_match(struct ib_qp *qp, struct rdma_counter *counter, ...@@ -149,13 +149,11 @@ static bool auto_mode_match(struct ib_qp *qp, struct rdma_counter *counter,
struct auto_mode_param *param = &counter->mode.param; struct auto_mode_param *param = &counter->mode.param;
bool match = true; bool match = true;
if (rdma_is_kernel_res(&counter->res) != rdma_is_kernel_res(&qp->res)) if (!rdma_is_visible_in_pid_ns(&qp->res))
return false; return false;
/* Ensure that counter belong to right PID */ /* Ensure that counter belongs to the right PID */
if (!rdma_is_kernel_res(&counter->res) && if (task_pid_nr(counter->res.task) != task_pid_nr(qp->res.task))
!rdma_is_kernel_res(&qp->res) &&
(task_pid_vnr(counter->res.task) != current->pid))
return false; return false;
if (auto_mask & RDMA_COUNTER_MASK_QP_TYPE) if (auto_mask & RDMA_COUNTER_MASK_QP_TYPE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment