drm/amdgpu: reject UALink peers outside the vPod active set
Subsystems (2)
PATCH 1/1 drm/amdgpu: reject UALink peers outside the vPod active set
remote->peer[] is only set up for active vPod members other than this GPU, but the import ioctl and HELLO processing only range-check the accelerator id. An unused id makes connection setup run on a zeroed
peer: an uninitialized mutex and scheduler entity, and GPU address 0.
Reject such ids in the import ioctl, connection setup and HELLO processing.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +33 -0
@@ -58,6 +58,8 @@ static void amdgpu_ualink_reset_peer_rings(struct amdgpu_device *adev, u32 remote_accel_id);static int amdgpu_ualink_ring_resync_ptrs (struct amdgpu_device *adev,u32 remote_accel_id); +static bool amdgpu_ualink_peer_is_set_up (struct amdgpu_device *adev, +u32 accel_id);#define STRIP_NPA (addr) \ (((u64)(addr) & ~AMDGPU_UALINK_NPA_ADDR_GPUID_MASK))
@@ -2280,6 +2282,13 @@ static void amdgpu_ualink_process_hello_msg(struct amdgpu_device *adev,return ; } +if (!amdgpu_ualink_peer_is_set_up (adev, sender_acc_id)) { +dev_err_ratelimited (adev->dev, +"HELLO: sender AccId:%u is not in the vPod\n" , + sender_acc_id); +return ; + } + conn_state = &adev->ualink.conn_state[sender_acc_id];/* Check if connection is already established. If yes, then receiving HELLO msg
@@ -2353,6 +2362,9 @@ static int amdgpu_ualink_setup_connection(struct amdgpu_device *adev,struct amdgpu_ualink_connection *conn_state;int r; +if (!amdgpu_ualink_peer_is_set_up (adev, remote_acc_id)) +return -EINVAL ; + conn_state = &adev->ualink.conn_state[remote_acc_id];/* Connection state management goes through different states.
@@ -3899,6 +3911,13 @@ int amdgpu_ualink_import_handle(struct drm_device *dev,return amdgpu_ualink_local_import (adev, remote_acc_id, &handle, fd_out); +if (!amdgpu_ualink_peer_is_set_up (adev, remote_acc_id)) { +dev_dbg (adev->dev, +"IMPORT: remote AccId:%u is not in the vPod\n" , + remote_acc_id); +return -EINVAL ; + } +xa_lock (&adev->ualink.imp_xa); imp_xa_node =xa_load (&adev->ualink.imp_xa, handle.handle_lo);
@@ -4506,6 +4525,20 @@ static inline enum amdgpu_ualink_addr_mode ualink_addr_mode(struct amdgpu_devicereturn adev->ualink.info->vpod.addr_mode; } +/* +* remote->peer[] (lock, scheduler entity, ring addresses and sizes) is only +* set up for members of the activation-time snapshot, excluding this GPU. +*/ +static bool amdgpu_ualink_peer_is_set_up (struct amdgpu_device *adev, +u32 accel_id) +{ +struct amdgpu_ualink_remote *remote =to_remote (adev); + +return remote && accel_id <AMDGPU_UALINK_ACCEL_MAX && + accel_id !=ualink_accel_id (adev) && +test_bit (accel_id, remote->active_accel_bits); +} +/* * address mode and NPA address for ring wptr, rptr, wb status, wb data *
Signature · 1 line
2.56.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/amdgpu: missing Fixes trailers on UALink peer validation bug-fix commit --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] drm/amdgpu: missing Fixes trailers on UALink peer validation bug-fix commit
--
commit 37d1bf77df3bc8c5b8bf6a9b288a54b6e7fd9a36
Author: Mukul Joshi <[email protected]>
Quoted 11 lines
drm/amdgpu: reject UALink peers outside the vPod active set
remote->peer[] is only set up for active vPod members other than this GPU, but the import ioctl and HELLO processing only range-check the accelerator id. An unused id makes connection setup run on a zeroed
peer: an uninitialized mutex and scheduler entity, and GPU address 0.Reject such ids in the import ioctl, connection setup and HELLO processing.
Signed-off-by Mukul Joshi <[email protected]>
[Severity: Low]
This fixes missing active vPod peer checks in the connection management and import ioctl paths. Should this include:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1