stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.15 01/17] drm/displayid: add displayid_get_header() and check bounds better
@ 2023-05-01  3:04 Sasha Levin
  2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 02/17] drm/amd/display: Use DC_LOG_DC in the trasform pixel function Sasha Levin
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Sasha Levin @ 2023-05-01  3:04 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jani Nikula, Iaroslav Boliukin, Dmitry Osipenko, Sasha Levin,
	maarten.lankhorst, mripard, tzimmermann, airlied, daniel,
	dri-devel

From: Jani Nikula <jani.nikula@intel.com>

[ Upstream commit 5bacecc3c56131c31f18b23d366f2184328fd9cf ]

Add a helper to get a pointer to struct displayid_header. To be
pedantic, add buffer overflow checks to not touch the base if that
itself would overflow.

Cc: Iaroslav Boliukin <iam@lach.pw>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/4a03b3a5132642d3cdb6d4c2641422955a917292.1676580180.git.jani.nikula@intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/drm_displayid.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_displayid.c b/drivers/gpu/drm/drm_displayid.c
index 32da557b960fd..82b7f0bb44097 100644
--- a/drivers/gpu/drm/drm_displayid.c
+++ b/drivers/gpu/drm/drm_displayid.c
@@ -7,13 +7,28 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_print.h>
 
+static const struct displayid_header *
+displayid_get_header(const u8 *displayid, int length, int index)
+{
+	const struct displayid_header *base;
+
+	if (sizeof(*base) > length - index)
+		return ERR_PTR(-EINVAL);
+
+	base = (const struct displayid_header *)&displayid[index];
+
+	return base;
+}
+
 static int validate_displayid(const u8 *displayid, int length, int idx)
 {
 	int i, dispid_length;
 	u8 csum = 0;
 	const struct displayid_header *base;
 
-	base = (const struct displayid_header *)&displayid[idx];
+	base = displayid_get_header(displayid, length, idx);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
 		      base->rev, base->bytes, base->prod_id, base->ext_count);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-05-01  3:17 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-01  3:04 [PATCH AUTOSEL 5.15 01/17] drm/displayid: add displayid_get_header() and check bounds better Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 02/17] drm/amd/display: Use DC_LOG_DC in the trasform pixel function Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 03/17] regmap: cache: Return error in cache sync operations for REGCACHE_NONE Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 04/17] arm64: dts: qcom: msm8996: Add missing DWC3 quirks Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 05/17] media: cx23885: Fix a null-ptr-deref bug in buffer_prepare() and buffer_finish() Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 06/17] media: pci: tw68: Fix null-ptr-deref bug in buf prepare and finish Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 07/17] memstick: r592: Fix UAF bug in r592_remove due to race condition Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 08/17] firmware: arm_sdei: Fix sleep from invalid context BUG Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 09/17] ACPI: EC: Fix oops when removing custom query handlers Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 10/17] remoteproc: stm32_rproc: Add mutex protection for workqueue Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 11/17] drm/tegra: Avoid potential 32-bit integer overflow Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 12/17] drm/msm/dp: Clean up handling of DP AUX interrupts Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 13/17] ACPICA: Avoid undefined behavior: applying zero offset to null pointer Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 14/17] ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 15/17] media: cros-ec-cec: Don't exit early in .remove() callback Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 16/17] drm/amd: Fix an out of bounds error in BIOS parser Sasha Levin
2023-05-01  3:04 ` [PATCH AUTOSEL 5.15 17/17] media: Prefer designated initializers over memset for subdev pad ops Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).