Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB678606A322 for ; Fri, 4 Dec 2026 14:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=MJRC7FX7 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C220112FD5; Fri, 4 Dec 2026 14:42:27 +0000 (UTC) Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012008.outbound.protection.outlook.com [40.107.209.8]) by gabe.freedesktop.org (Postfix) with ESMTPS id 60762112FD5 for ; Fri, 4 Dec 2026 14:42:17 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DVERpLeLOuV+G+jPPPPokTGwfQSSQs3Qp6ObfoAo2LwTmJrDEwKVU6ce0PlUaGT+CIp3OkdZ04lml59gFL2ByvLPGisDKCnVPrflNpxOL/7TI5+68gcLzAC3pQz/m8RK3lxN4dWmK55uiVjZpVS4DKtzzdhVw7t7am8qdh6lh5Hr/sDcunx9eQkw+sWghTBNYuyfR1kJFCo1Vw8MoT/Pckzew9MSwhteppg5FuSfy4NYfpxkSunWOpiumlWfIouXphMW2VN9sQ9qA3pmimUPZq+GCNaLeVw0ADHM9hyGOBWfz3YjzfwC3X1jyz1EGfB8bhKA5C8DwfoQJbyX9ZjRpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LoOJPKODwWBpr2O5OJcpfrCutrKBRa+4rNiQcqJoLIg=; b=in2K750rI2GzOCmzLqZMeLfnI81P260C+GZ0OzceaehjL+gwhC6D1AfDHiQWzv2pDTRTqc3xMnFPZFG+lxxArues0qWZuj8yhAXkL3Cxq7EByroIGehMt5b/+0Z8xwbeQ707ZIcXF1/YA2B/oKeMqBRBQvkQI8etXgg1rr2mnxAJP+K+NarnGUU6bHJa9ne6EUDfoteXM3g/zRhMjevYqGeiK3nyLkr45ilASDEAdk8vNquq/3qG50O2EPa82Y+xctZT+3CQP0V/P8d+AEgIpCMtSHOdVArPU9MM623+jaJl2FLa2qSE0qgeoNZVfn2xFmuEprfN2EDKOG5+SGpV6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LoOJPKODwWBpr2O5OJcpfrCutrKBRa+4rNiQcqJoLIg=; b=MJRC7FX71BmuBNaEW24M31gQCYLriE2aKWUYaUsPaUXO0ak4cf0s9R/8htnUVUrQOpWyagMhvzmEfITPv+6UNHP+PBMFxCD106GL5rZZr/qcG+qThONqnFbIS6HnBWBpLjaz4SrJTsVQEDPa7Qjo30A7UvW0lr5n7gE/pRoh4yY= Received: from BN1PR13CA0024.namprd13.prod.outlook.com (2603:10b6:408:e2::29) by DS5PR12MB106944.namprd12.prod.outlook.com (2603:10b6:8:47c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 14:42:10 +0000 Received: from LV8PEPF0000006B.namprd03.prod.outlook.com (2603:10b6:408:e2:cafe::25) by BN1PR13CA0024.outlook.office365.com (2603:10b6:408:e2::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.709.7 via Frontend Transport; Fri, 4 Dec 2026 14:42:10 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by LV8PEPF0000006B.mail.protection.outlook.com (10.167.248.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 14:42:10 +0000 Received: from mukjoshi-dev.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 08:42:09 -0600 From: Mukul Joshi To: CC: , , , Mukul Joshi Subject: [PATCHv2] drm/amdgpu: reject UALink peers outside the vPod active set Date: Fri, 4 Dec 2026 09:41:29 -0500 Message-ID: <20261204144157.965052-1-mukul.joshi@amd.com> X-Mailer: git-send-email 2.56.0 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV8PEPF0000006B:EE_|DS5PR12MB106944:EE_ X-MS-Office365-Filtering-Correlation-Id: 21e7f400-16e8-4e29-cbbf-08df5214c730 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|23010399003|376014|1800799024|36860700016|11063799006|261009223027099003|18002099003|10067099003|56012099006|261022075727099003|261022113327099003|261102123227099003|261021121427099003|261026121527099003; X-Microsoft-Antispam-Message-Info: 2YSA/zt/mD2zVhRVQxf39vdmHauqUDTI3Po2L8hFWVgWFMqg1GbmEhbMeCVCOnnrp2tqKQWXweRPSAWrXgHnBFMVbqjWs9jK0xK/nuRPwUHC3cVRg9WB2TSoBZvXa5xlCrE0MzL6ORsNhyodgwKX8GjWnCWgMHXZRAIsM1e/2Utvg0+3qQfGiLqCVlkvzfie+efWHRplQ6Ur9ef/1dBIoFbttzweEvc0ANzWPHwrWWFMjzZCyKwEJKXWhlqaFE4FzmIFxGF4OReB3jnh8yFBKua3dsWson32w6LXtRHQinJEQme7+UVGesmHzqJX7VofuLomhxxs4rSXCK9MrxQ9FDrmHYWgj2MPpc2y8qQjxXCwwzEafDBWp0cBVqFtBno+oSi1bDVje6XciXzoQXhYUDIKfBMhjQiedIBey9SoEOSHII4KczNp0ggRksErl2ZGhLmpLJDtl7vTRaKk76eTsCngsx50vjbzASgtdGbyJpOTHuZpqnawzwrRzK2WOqge74ArMwTKo9nW7JEn6QT94VrkZoe9rGfw5Jlvpit2aHtul+vlUd0B5v7chF0+2JLtTPh5OPFSQkMALWGjy+cdB78/MfFJAWkUva5KUqPKtEZpX6XXZqcc7JHprEQ2iqpbXvuCte4mB/kzG7g1dQJ/L1Tmvnz70DIY6ClxJ1ckN0reEaPjaEzogo3NU/CPKuQb/QBwL77QskBVWv+z3UD1GA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(23010399003)(376014)(1800799024)(36860700016)(11063799006)(261009223027099003)(18002099003)(10067099003)(56012099006)(261022075727099003)(261022113327099003)(261102123227099003)(261021121427099003)(261026121527099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Aj5qqQXccmItt7ocSeVgLusN97bpp6Z5WnuCC2lvADE47m7G/pPbB1C9wIl1urRGpw/96wgEG5Ayt0BVavCTwrUvKIhs5TVgrc+Jmxf+o3qtvPtPFtBLqHYLXeN8pASA+gGPCVsBQC6EDdOIR8Mlqhqa5tZJ8hjfAk/XrTlvVYbg2PnGYGwhhQ+jdqVD+3bd1d53U50IOv56uRdq7+dc8R3U5lVFT6VUOa+QxNWudotlNJUT0k2pCmHNgaECmASNw98YdjolDMnI+CWcTHYJC83ERniKh8MDNCz37AHZG8+4v0II5EISX4AcOqzi9ZcCwkZ39Yqc5/gkYh0gaq0S/TETrYJ3ELJ1mOCAWxG5P4vh3vm/fEOLszB8Z+sgQR3UNcU6CDChvWYL1jjNFz7VHh8toMNPqju/26YTc4B3htwwRdj8WrW89WRdHMHFDkEb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 14:42:10.4136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21e7f400-16e8-4e29-cbbf-08df5214c730 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: LV8PEPF0000006B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS5PR12MB106944 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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. Fixes: 8c583a03f24c ("drm/amdgpu: Implement UALink handle import ioctl") Fixes: aa574f2570d6 ("drm/amdgpu: Resync UALink ring wptr after reboot") Signed-off-by: Mukul Joshi --- v1->v2: - Add the Fixes tag. drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c index 0ce5faccfda7..6dcaf297a496 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c @@ -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_device return 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 * -- 2.56.0