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 007682E7379; Sat, 30 May 2026 17:31:28 +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=1780162289; cv=none; b=t2KtMay7IbmCbWqrY4F+FrxcGwWViAZmrEf/TUYxR9kVfxbdrvTl52G2tNfASHCLYDALKT/dgfA0zW932IclMIzsEvlmi6sW6Dc+ZVMVMharm8KcXk8fSImA7kbtl3OjVGryU3BlTk9Tqn/bYsSsaHSoX6/6yuKmOgput8gh4Xs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162289; c=relaxed/simple; bh=1xuH/34sczTn3p2kcWbVBCI0yR+S+UHb62I6fGY4q/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R9zaIm5MMjhtFcGQ+xAxhXWq6MzcsrdJAcnIYxC8AUJwqr8akJiVobfWtk4p2y7huuCyf+bCLqGxmmfCDcc+iSEYHejqUaQVLi9kBRESb+SpoYlZUhxr4J2kpjYZI64ruxM+2SydYkvAJKr8MGfTtW95Ebe4+W2pg/fiUQxSiC8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kOOKdt/c; 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="kOOKdt/c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07CD31F00893; Sat, 30 May 2026 17:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780162288; bh=z0co9dQSBFJhk619Q3+mTFgPgHSdfWBB40cHa1o+830=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kOOKdt/cOPxCnjgWWCGql0s547+lE1C6gpX5S6f+A2TGNWPSblDEJLLZ+cn3OVxzv a+AxnjpdWA2XwlCDAUY1A2bV6iPc/yU1MEGaFLnZMF4L6TV7oAwBo9RyL1OqPJVBcz gaMbtJMALCF2z8GGOwlO8N1Icid16NAguYF78NjI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alex Hung , Harry Wentland , Ivan Lipski , Dan Wheeler , Alex Deucher Subject: [PATCH 6.1 877/969] drm/amd/display: Fix integer overflow in bios_get_image() Date: Sat, 30 May 2026 18:06:41 +0200 Message-ID: <20260530160324.905725762@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Harry Wentland commit cd86529ec61474a38c3837fb7823790a7c3f8cce upstream. [Why&How] The bounds check in bios_get_image() computes 'offset + size' using unsigned 32-bit arithmetic before comparing against bios_size. If a VBIOS image contains a near-UINT32_MAX offset the addition wraps to a small value, the comparison passes, and the function returns a wild pointer past the VBIOS mapping. Additionally, the comparison uses '<' (strict), which incorrectly rejects the valid exact-fit case where offset + size == bios_size. Fix both issues by restructuring the check to avoid the addition entirely: first reject if offset alone exceeds bios_size, then check size against the remaining space (bios_size - offset). This eliminates the overflow and correctly permits exact-fit accesses. Assisted-by: GitHub Copilot:claude-opus-4.6 Reviewed-by: Alex Hung Signed-off-by: Harry Wentland Signed-off-by: Ivan Lipski Tested-by: Dan Wheeler Signed-off-by: Alex Deucher (cherry picked from commit d40fb392af659c4a02b560319f226842f6ec1a95) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c @@ -37,10 +37,13 @@ uint8_t *bios_get_image(struct dc_bios * uint32_t offset, uint32_t size) { - if (bp->bios && offset + size < bp->bios_size) - return bp->bios + offset; - else + if (!bp->bios) return NULL; + + if (offset > bp->bios_size || size > bp->bios_size - offset) + return NULL; + + return bp->bios + offset; } #include "reg_helper.h"