From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AC533AB267; Tue, 16 Jun 2026 15:41:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781624469; cv=none; b=PzzbPddnVSwgaMLXcHkTi+ER3/l0RUT7TpKTTcDk9RF1m1DYxeJFgUgoCMc7Qt6WgE+p9Uh1otl9kBs6gtKcAUqreMXBQsSGi3XBrw3gn2R9Ah0Qjk0MI2SEjH4+v5hGejMIpXpScAsy61XUNFrGw1PUcl+iPiFcz7R5mwzxYM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781624469; c=relaxed/simple; bh=PI9XTcWLGrj9xkOhBoVpuhKfduzuXX+yjh4nEEeeU1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qBqGTU4IIYalfdlSMQ3V1squ7pUAam9Q33izeOyljP1Ee1MTb6TaF80QyYH1bie3vaGvawPAqIPYMYrafxlThnuy2Z+LB9C0GAfkhS6q+pyDAUbY76G4rkAxU7JFzJtaf/MF576DthRkb8Mdik0i98k+3BaELeU0P+2Supj2a2w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NIwNtYiV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NIwNtYiV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EA691F00A3D; Tue, 16 Jun 2026 15:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781624468; bh=j7sqdaYY5Pb1uYIDhS1wmP95ws+yTzLvLX4+zSvdCxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NIwNtYiVuAs3/GlcLHR5PeWrJQMnzAP3tW+qETmRVdmj7i8CkY6EK1gqSDpMScDxC yF5gRgC3JKLfcB63O2UxnoK+okAAOkWvNGK2uJKWgLNmb24gC9JbYiR1uOC/NSekpG bBKZ1o6l0R83oJpEY5SeErz5bxbq9jstWvs4WrIY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Muhammad Bilal , Alex Deucher Subject: [PATCH 7.0 335/378] drm/amdkfd: fix NULL dereference in get_queue_ids() Date: Tue, 16 Jun 2026 20:29:26 +0530 Message-ID: <20260616145127.853360537@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145109.744539446@linuxfoundation.org> References: <20260616145109.744539446@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Muhammad Bilal commit 2bd550b547deabef98bd3b017ff743b7c34d3a6d upstream. When usr_queue_id_array is NULL and num_queues is non-zero, get_queue_ids() returns NULL. The callers check only IS_ERR() on the return value; since IS_ERR(NULL) == false the check passes, and suspend_queues() calls q_array_invalidate() which immediately dereferences NULL while iterating num_queues times. Userspace can trigger this via kfd_ioctl_set_debug_trap() by supplying num_queues > 0 with a zero queue_array_ptr, causing a kernel panic. A NULL usr_queue_id_array with num_queues == 0 is a legitimate no-op (q_array_invalidate never executes, and resume_queues already guards all queue_ids dereferences behind a NULL check). Return ERR_PTR(-EINVAL) only when num_queues is non-zero and the pointer is absent; both callers already propagate IS_ERR() returns correctly to userspace. Fixes: a70a93fa568b ("drm/amdkfd: add debug suspend and resume process queues operation") Signed-off-by: Muhammad Bilal Signed-off-by: Alex Deucher (cherry picked from commit f165a82cdf503884bb1797771c61b2fcc72113d4) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -3297,7 +3297,7 @@ static void copy_context_work_handler(st static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array) { if (!usr_queue_id_array) - return NULL; + return num_queues ? ERR_PTR(-EINVAL) : NULL; if (num_queues > KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) return ERR_PTR(-EINVAL);