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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue, 04 Jun 2024 23:41:24 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Lyndon Sanche <lsanche@...deno.ca>, Hans de Goede <hdegoede@...hat.com>, 
 Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Cc: platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org, 
 Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH] platform/x86: dell-pc: avoid double free and invalid
 unregistration

If platform_profile_register() fails it does kfree(thermal_handler) and
leaves the pointer value around.
Any call to thermal_cleanup() will try to kfree(thermal_handler) again.
This will happen right away in dell_init().
In addition, platform_profile_remove() will be called although no
profile is registered.

NULL out the thermal_handler, so thermal_cleanup() avoids the double free.

Fixes: 996ad4129810 ("platform/x86: dell-pc: Implement platform_profile")
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
Currently the call to thermal_cleanup() in dell_init() is completely
unnecessary. But I guess more functionality will be handled by the
driver and then this structure makes sense.

This is untested.
---
 drivers/platform/x86/dell/dell-pc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index dfe09c463d03..972385ca1990 100644
--- a/drivers/platform/x86/dell/dell-pc.c
+++ b/drivers/platform/x86/dell/dell-pc.c
@@ -261,8 +261,10 @@ static int thermal_init(void)
 
 	/* Clean up if failed */
 	ret = platform_profile_register(thermal_handler);
-	if (ret)
+	if (ret) {
 		kfree(thermal_handler);
+		thermal_handler = NULL;
+	}
 
 	return ret;
 }

---
base-commit: 0da7a954480cc99978e3570c991e3779e56fc736
change-id: 20240604-dell-pc-double-free-e8cf2aa9b2fb

Best regards,
-- 
Thomas Weißschuh <linux@...ssschuh.net>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ