lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed,  6 Dec 2023 15:27:01 +0800
From:   Dinghao Liu <dinghao.liu@....edu.cn>
To:     dinghao.liu@....edu.cn
Cc:     Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Maxime Ripard <mripard@...nel.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        David Airlie <airlied@...il.com>,
        Daniel Vetter <daniel@...ll.ch>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/plane: fix error handling in __drm_universal_plane_init

__drm_universal_plane_init() frees plane->format_types and
plane->modifiers on failure. However, sometimes its callers
will free these two pointers again, which may lead to a
double-free. One possible call chain is:

mdp5_plane_init
  |-> drm_universal_plane_init
  |     |-> __drm_universal_plane_init (first free)
  |
  |-> mdp5_plane_destroy
        |-> drm_plane_cleanup (second free)

Fix this by setting the two pointers to NULL after kfree.

Signed-off-by: Dinghao Liu <dinghao.liu@....edu.cn>
---
 drivers/gpu/drm/drm_plane.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 24e7998d1731..1331b8224920 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -304,6 +304,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 	if (format_modifier_count && !plane->modifiers) {
 		DRM_DEBUG_KMS("out of memory when allocating plane\n");
 		kfree(plane->format_types);
+		plane->format_types = NULL;
 		drm_mode_object_unregister(dev, &plane->base);
 		return -ENOMEM;
 	}
@@ -317,6 +318,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 	if (!plane->name) {
 		kfree(plane->format_types);
 		kfree(plane->modifiers);
+		plane->format_types = NULL;
+		plane->modifiers = NULL;
 		drm_mode_object_unregister(dev, &plane->base);
 		return -ENOMEM;
 	}
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ