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 220E4477E36; Tue, 16 Jun 2026 16:36:27 +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=1781627788; cv=none; b=SakQHfBoBXZqJ7+idqTxYZqi0AU3XRauO9Ii2Hjc2LEWZc24wgQXJGFOJEjJlS8a4NarVp2DyeFxOFognzNegVz9ZZlXon4gfq6bMITuq1w0eZkTNSv8o/FO8CS/KiQQFU//EdMU1qWGzTs+yIs+NvRs4LbnAD02vE1V7IAGNL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781627788; c=relaxed/simple; bh=fjUyPaluSIzBYmdzamEM3IiiPWZPSLSFvu954fvfvE8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hAxLXaUhVT1/SHlyoMXRQJSgTBWylN/bHyDFEMm3+RH8Z7VAznm11g6N+spHJ1tgFJkM8qfNo2GFXBxdw7yJv0HYFtblbNwoWZTApx+4h+CTEfZiIMd7IvXKbYLM60FFNoC1n6P5C8CDARqZ2WudszOFEUq//qm/IpB86T/XIGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IGq0laOJ; 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="IGq0laOJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ED331F000E9; Tue, 16 Jun 2026 16:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781627787; bh=6J8tPgVqrDfAu8qmHsr9RM2aIhZ8QSv+rsDln29Jsfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IGq0laOJ5XzO795kYBg5oRaylq2ZBYnCaxV9KcwfHfmx/4e1JUxLz9i/sjT/uKBdQ zzsMzuPKHuDhSYDiqtS3EWPTGFgVSL4KBJLEJP481R/Jcc6jEQqi0eaJWB68UgPyBe EHYLIKXyb9vOWDesT8q73PqYgqIZfUtRXbO0qVeU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alex Hung , Harry Wentland , Ray Wu , Daniel Wheeler , Alex Deucher Subject: [PATCH 6.12 228/261] drm/amd/display: Use krealloc_array() in dal_vector_reserve() Date: Tue, 16 Jun 2026 20:31:06 +0530 Message-ID: <20260616145055.596501149@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145044.869532709@linuxfoundation.org> References: <20260616145044.869532709@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Harry Wentland commit da48bc4461b8a5ebfb9264c9b191a701d8e99009 upstream. [Why & How] dal_vector_reserve() computes the allocation size as "capacity * vector->struct_size" using uint32_t arithmetic, which can silently wrap to a small value on overflow. This would cause krealloc to return a smaller buffer than expected, leading to heap overflows on subsequent vector appends. Replace krealloc() with krealloc_array() which performs an internal overflow check and returns NULL on wrap, preventing the issue. Fixes: 2004f45ef83f ("drm/amd/display: Use kernel alloc/free") Assisted-by: Copilot:claude-opus-4.6 Reviewed-by: Alex Hung Signed-off-by: Harry Wentland Signed-off-by: Ray Wu Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher (cherry picked from commit 37668568641ccc4cc1dbca4923d0a16609dd5707) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/dc/basics/vector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/amd/display/dc/basics/vector.c +++ b/drivers/gpu/drm/amd/display/dc/basics/vector.c @@ -288,8 +288,8 @@ bool dal_vector_reserve(struct vector *v if (capacity <= vector->capacity) return true; - new_container = krealloc(vector->container, - capacity * vector->struct_size, GFP_KERNEL); + new_container = krealloc_array(vector->container, + capacity, vector->struct_size, GFP_KERNEL); if (new_container) { vector->container = new_container;