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 6E3272F1FEF; Thu, 28 May 2026 20:49:50 +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=1780001393; cv=none; b=eCqtCQEObWxE/eA0XpQkuQxdiPKNCA/YjJaZToe+aQ47OBTJgQHmne4nWuyj9SHHroXkWrWzguWoJdXF/NF/pKJcfzyl4TTfUmIIszS45zypHHgNfVKCfYxbOXiiTo4fIDUugp/Pn6cGhTiw2/0uFZ4c7lfeAKTWk+vpPUJaTTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780001393; c=relaxed/simple; bh=Kbbd6kkT8U0qG7Hlte6Avu9qetA3Z12YOreuWe2GjWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MloNMk5UW+I38fTxk59U5GdfCfnUgP1fYyh019yhfTz9GCGORrYlzkRMUy4Q9S5tb5kvH8/k6mafuGE4ZKE0bZ4bPUSiTBqNgKhBAvlY9dzbe+6JotrDtcKsoJzttgOqlXt6oeAt7Z44H0YJs2FoX3FObm6H4ntD0hfbhp9rKwQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=h8Yloa+L; 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="h8Yloa+L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 474C41F000E9; Thu, 28 May 2026 20:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780001389; bh=L37ajHslYT54G1ivTa0Q4ioQFY3IfupaM1Yu/y5IApU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=h8Yloa+LEzHdtiGK6gGQRsf6DY8rcUJQbkEzaXP4JhjX7vKXN23Cee010BqJ/Rs5I Z8NoQ+835cq3BEUjQ/4lVbr5KiqUdwRaPYIAydmzABs8+0JcY7NRI7kKj5hBUYJviK 48wOo0HzlOIrcUEEYtskIC5lhXjIIbpGcpgsIux0= 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.6 073/186] drm/amd/display: Fix integer overflow in bios_get_image() Date: Thu, 28 May 2026 21:49:13 +0200 Message-ID: <20260528194930.911901807@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194928.941004471@linuxfoundation.org> References: <20260528194928.941004471@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-Transfer-Encoding: 8bit 6.6-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"