Skip to content

Commit 4ae45a6

Browse files
author
Benjamin Poirier
committed
RDMA/mlx5: Reorder capability check last
JIRA: https://issues.redhat.com/browse/RHEL-72227 JIRA: https://issues.redhat.com/browse/RHEL-73520 Upstream-status: v6.15-rc1 commit 3745242 Author: Christian Göttsche <cgzones@googlemail.com> Date: Sun Mar 2 17:06:47 2025 +0100 RDMA/mlx5: Reorder capability check last capable() calls refer to enabled LSMs whether to permit or deny the request. This is relevant in connection with SELinux, where a capability check results in a policy decision and by default a denial message on insufficient permission is issued. It can lead to three undesired cases: 1. A denial message is generated, even in case the operation was an unprivileged one and thus the syscall succeeded, creating noise. 2. To avoid the noise from 1. the policy writer adds a rule to ignore those denial messages, hiding future syscalls, where the task performs an actual privileged operation, leading to hidden limited functionality of that task. 3. To avoid the noise from 1. the policy writer adds a rule to permit the task the requested capability, while it does not need it, violating the principle of least privilege. Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Link: https://patch.msgid.link/20250302160657.127253-10-cgoettsche@seltendoof.de Reviewed-by: Serge Hallyn <serge@hallyn.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Benjamin Poirier <bpoirier@redhat.com>
1 parent 2cd5653 commit 4ae45a6

File tree

1 file changed

+6
-4
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+6
-4
lines changed

drivers/infiniband/hw/mlx5/devx.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,14 @@ int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user)
136136
return -EINVAL;
137137

138138
uctx = MLX5_ADDR_OF(create_uctx_in, in, uctx);
139-
if (is_user && capable(CAP_NET_RAW) &&
140-
(MLX5_CAP_GEN(dev->mdev, uctx_cap) & MLX5_UCTX_CAP_RAW_TX))
139+
if (is_user &&
140+
(MLX5_CAP_GEN(dev->mdev, uctx_cap) & MLX5_UCTX_CAP_RAW_TX) &&
141+
capable(CAP_NET_RAW))
141142
cap |= MLX5_UCTX_CAP_RAW_TX;
142-
if (is_user && capable(CAP_SYS_RAWIO) &&
143+
if (is_user &&
143144
(MLX5_CAP_GEN(dev->mdev, uctx_cap) &
144-
MLX5_UCTX_CAP_INTERNAL_DEV_RES))
145+
MLX5_UCTX_CAP_INTERNAL_DEV_RES) &&
146+
capable(CAP_SYS_RAWIO))
145147
cap |= MLX5_UCTX_CAP_INTERNAL_DEV_RES;
146148

147149
MLX5_SET(create_uctx_in, in, opcode, MLX5_CMD_OP_CREATE_UCTX);

0 commit comments

Comments
 (0)