All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] class: fix use-after-free in class_register()
@ 2023-12-18  2:44 Chunyan Zhang
  2023-12-18  6:52 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Chunyan Zhang @ 2023-12-18  2:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: LKML, Jing Xia, Jing Xia, Xuewen Yan, Ke Wang, Chunyan Zhang

From: Jing Xia <jing.xia@unisoc.com>

The lock_class_key is still registered and can be found in
lock_keys_hash hlist after subsys_private is freed in error
handler path.A task who iterate over the lock_keys_hash
later may cause use-after-free.So fix that up and unregister
the lock_class_key before kfree(cp).

Signed-off-by: Jing Xia <jing.xia@unisoc.com>
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
 drivers/base/class.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 7e78aee0fd6c..7b38fdf8e1d7 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -213,6 +213,7 @@ int class_register(const struct class *cls)
 	return 0;
 
 err_out:
+	lockdep_unregister_key(key);
 	kfree(cp);
 	return error;
 }
-- 
2.25.1


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

end of thread, other threads:[~2023-12-18 10:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-18  2:44 [PATCH] class: fix use-after-free in class_register() Chunyan Zhang
2023-12-18  6:52 ` Greg Kroah-Hartman
2023-12-18  6:53   ` Greg Kroah-Hartman
2023-12-18 10:41   ` jing xia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.