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 013C343D4E8; Tue, 16 Jun 2026 17:11:12 +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=1781629874; cv=none; b=kHNapBB16OdVIEVNF3r4MHNyQpo7LTwVR1pbSW2vv8bp6kOmSjKL5woKDoiyxC7YozTzDaV+5yUZHKmyX5wKb1GWRHxeE37Zq+xh/kz0WCDtZ8IneC3Zm0QBskypARSJ6RsJmo0g+P5UHNoCPZ+St9ovplQbHp5174hq0Oy7ELk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781629874; c=relaxed/simple; bh=hyokYjUU9sOIRRraBPJZ2ngiDMyxk881YlGllkf5dOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a2FlRxS71je1R1GN7JG/A+qJTNvTun7PUk/G09wAkVgzAhJr7ZzFmKZEz3hnlnbLk/3gMdsuMqGTYyumVqz52zbTFiRDIDTBMzSPDcCUHJXi2fnMkdr5LPLJaX9AQF7RzNn39/eFLPSyePPeCcUmfGOQjakFR0Lko0e1DpmrkQI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WEsvoUso; 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="WEsvoUso" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBC761F000E9; Tue, 16 Jun 2026 17:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781629872; bh=1apqmHeFLI0Q3/Ai5V6GRo6mbjKtlAfSBJRZoPkYqng=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WEsvoUsox69/WHDhfGOICOxPLbTG8FXvmxzk6wDzNP2MydbLtGNiW/cn0vmm2snZy qEeqLmewAZNzAj1SF4/QCWoIRgLqjk1EoG4O0AVFhAHeZR+uR3XQqOTGKKg3uZSM2Q rjmOIIErOyc/YelR93rd8x/HlzLrf182sjzIt70A= 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.6 367/452] drm/amd/display: Use krealloc_array() in dal_vector_reserve() Date: Tue, 16 Jun 2026 20:29:54 +0530 Message-ID: <20260616145136.340192172@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@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.6-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;