Skip to content

Commit c8b3240

Browse files
Leon Romanovskydledford
authored andcommitted
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: 99fa331 ("RDMA/counter: Add "auto" configuration mode support") Reviewed-by: Mark Zhang <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Doug Ledford <[email protected]>
1 parent 948a728 commit c8b3240

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/infiniband/core/counters.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,11 @@ static bool auto_mode_match(struct ib_qp *qp, struct rdma_counter *counter,
149149
struct auto_mode_param *param = &counter->mode.param;
150150
bool match = true;
151151

152-
if (rdma_is_kernel_res(&counter->res) != rdma_is_kernel_res(&qp->res))
152+
if (!rdma_is_visible_in_pid_ns(&qp->res))
153153
return false;
154154

155-
/* Ensure that counter belong to right PID */
156-
if (!rdma_is_kernel_res(&counter->res) &&
157-
!rdma_is_kernel_res(&qp->res) &&
158-
(task_pid_vnr(counter->res.task) != current->pid))
155+
/* Ensure that counter belongs to the right PID */
156+
if (task_pid_nr(counter->res.task) != task_pid_nr(qp->res.task))
159157
return false;
160158

161159
if (auto_mask & RDMA_COUNTER_MASK_QP_TYPE)

0 commit comments

Comments
 (0)