[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20211203153321.108049-1-zhou1615@umn.edu>
Date: Fri, 3 Dec 2021 23:33:21 +0800
From: Zhou Qingyang <zhou1615@....edu>
To: zhou1615@....edu
Cc: kjlu@....edu, Patrik Jakobsson <patrik.r.jakobsson@...il.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Dave Airlie <airlied@...hat.com>,
Alan Cox <alan@...ux.intel.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2] drm/gma500/cdv_intel_lvds: Fix a wild pointer dereference in cdv_intel_lvds_get_modes()
In cdv_intel_lvds_get_modes(), the return value of drm_mode_duplicate()
is assigned to mode and used in drm_mode_probed_add().
drm_mode_probed_add() passes mode->head to list_add_tail().
list_add_tail() will further call __list_add() and there is a
dereference of mode->head in __list_add(), which could lead to a wild
pointer dereference on failure of drm_mode_duplicate().
Fix this bug by adding a checking of mode
This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.
Builds with CONFIG_DRM_GMA500=m show no new warnings,
and our static analyzer no longer warns about this code.
Fixes: 6a227d5fd6c4 ("gma500: Add support for Cedarview")
Signed-off-by: Zhou Qingyang <zhou1615@....edu>
---
Changes in v2:
- Use dev_err and return instead of returning error code.
drivers/gpu/drm/gma500/cdv_intel_lvds.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
index 9e1cdb11023c..581fc8315631 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
@@ -310,6 +310,11 @@ static int cdv_intel_lvds_get_modes(struct drm_connector *connector)
if (mode_dev->panel_fixed_mode != NULL) {
struct drm_display_mode *mode =
drm_mode_duplicate(dev, mode_dev->panel_fixed_mode);
+ if (!mode) {
+ dev_err(dev->dev, "drm_mode_duplicate() failed.\n");
+ return 0;
+ }
+
drm_mode_probed_add(connector, mode);
return 1;
}
--
2.25.1
Powered by blists - more mailing lists