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 239F517C220; Fri, 15 May 2026 15:57:06 +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=1778860627; cv=none; b=eEN0CDUc6wsI2ocKuLV+nC1Y6X2MA9BPqLquByaHYCb6G2gDZvYL/iOZpP6+fLjfbwhw+XZA5CgSXptgOBv37GOm0VwYBm+qkq/Yxgg6nHl5h2HcsCWKT/BAudNIg2qzouwK3efz+jT8e2eEEBLuQdGRmrhJdSFVaAZbwvSAElI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778860627; c=relaxed/simple; bh=z5RRtlokMohDaDRrCIdkPD0ejpavWbIHUKvyORB2Bts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H+QM0a78H6nYBDou4AXcUAiRyMqaB1WpxvsPtAbH/90SoZslybQI6gI9PzGWHkEM8B74dStX5nns6HcySIFSv9cAEmnC8MhCSF/MKLmI/cMz3Q791MVByF/L6kn0vHD7BV1uKL6pAhixKa2vTHzLnPIK4BMyVRGiyViqF2+rVxk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZcYahP5Q; 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="ZcYahP5Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 612DFC2BCB3; Fri, 15 May 2026 15:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778860626; bh=z5RRtlokMohDaDRrCIdkPD0ejpavWbIHUKvyORB2Bts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZcYahP5QJNq4LSv2/jIK6ZeVtkIOdoflQy/edGCg+Ndt1oFMVbEL6LpggGZXlfZms qnYEKBVgGiBxXUsCcIumZhZUm9faOapSDQ1jzP+635L+PVlJ91cmgMuoytAJ/aANWw glojBzGiFhFE4dUJ2AkQBCteTWaCeC+Pfgz5qaaM= 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 , Fang Wang <32840572@qq.com>, Sasha Levin Subject: [PATCH 6.6 018/474] drm/amdgpu: Limit BO list entry count to prevent resource exhaustion Date: Fri, 15 May 2026 17:42:07 +0200 Message-ID: <20260515154715.447968880@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jesse.Zhang [ Upstream commit 6270b1a5dab94665d7adce3dc78bc9066ed28bdd ] 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: Fang Wang <32840572@qq.com> Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index db0a1c828fe15..4efdc49d1015f 100644 --- 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) { @@ -201,6 +202,9 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in, 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); -- 2.53.0