From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0A27D21D00A; Mon, 23 Mar 2026 13:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774274020; cv=none; b=a0FB+f42ISo+8ujKEG9ohbZAdZXkfZHTySadjQId2OvD/RS+dtaQ1XsiFQXCJ+C6Rkjn3TUrTCY4ffk27/UaSVnYXNu15CDal50SdezzeO04p6Q3nK8Xw/0x5SD6h3lVrDys+zC2rM2FxKAfvyIaaiSxSoXxNVitWnord7HJ3fY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774274020; c=relaxed/simple; bh=K0YJJH70MUULU9XnOQOhDycr0L52e1JJPTeMUi/firM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MKseid3iwwfK9XGWQSHR8h4MWPwf4nLKgge30C6ShiIJy53kw1Sv63WZT7YAFGC89S3wTu2nTVwlXa3o9fGbnZx9N2Zbpr2zRdklnCgAjUkAoBMWIxMPHQU9ji63QkDXdoUKDbVRuJ2Ybnf5oowH06ZBb5xfmMIJHVfpdpmL39c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=moEfEmSq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="moEfEmSq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82DC2C2BC9E; Mon, 23 Mar 2026 13:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774274019; bh=K0YJJH70MUULU9XnOQOhDycr0L52e1JJPTeMUi/firM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=moEfEmSqcQmPHLoepoTigQ5sj5HfDwbI1z5poX0MBC1zH+RMkZmptbSFDasbFnG3I IztIxCvWpLJa2INfHuNRJG4K2J3Z7T9lCtU3FS0zmgqWWwp6J3GDDjUTkiPWZfb8Lb AxO2xPS2uD7b4+LCNL/HNN9ldAziYNqnSN0y0+YI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Christian=20K=C3=B6nig?= , Jesse Zhang , Alex Deucher Subject: [PATCH 6.19 084/220] drm/amdgpu: Limit BO list entry count to prevent resource exhaustion Date: Mon, 23 Mar 2026 14:44:21 +0100 Message-ID: <20260323134507.249294514@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134504.575022936@linuxfoundation.org> References: <20260323134504.575022936@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jesse.Zhang commit 6270b1a5dab94665d7adce3dc78bc9066ed28bdd upstream. Userspace can pass an arbitrary number of BO list entries via the bo_number field. Although the previous multiplication overflow check prevents out-of-bounds allocation, a large number of entries could still cause excessive memory allocation (up to potentially gigabytes) and unnecessarily long list processing times. Introduce a hard limit of 128k entries per BO list, which is more than sufficient for any realistic use case (e.g., a single list containing all buffers in a large scene). This prevents memory exhaustion attacks and ensures predictable performance. Return -EINVAL if the requested entry count exceeds the limit Reviewed-by: Christian König Suggested-by: Christian König Signed-off-by: Jesse Zhang Signed-off-by: Alex Deucher (cherry picked from commit 688b87d39e0aa8135105b40dc167d74b5ada5332) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -36,6 +36,7 @@ #define AMDGPU_BO_LIST_MAX_PRIORITY 32u #define AMDGPU_BO_LIST_NUM_BUCKETS (AMDGPU_BO_LIST_MAX_PRIORITY + 1) +#define AMDGPU_BO_LIST_MAX_ENTRIES (128 * 1024) static void amdgpu_bo_list_free_rcu(struct rcu_head *rcu) { @@ -190,6 +191,9 @@ int amdgpu_bo_create_list_entry_array(st const uint32_t bo_number = in->bo_number; struct drm_amdgpu_bo_list_entry *info; + if (bo_number > AMDGPU_BO_LIST_MAX_ENTRIES) + return -EINVAL; + /* copy the handle array from userspace to a kernel buffer */ if (likely(info_size == bo_info_size)) { info = vmemdup_array_user(uptr, bo_number, info_size);