[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231218024403.1076134-1-chunyan.zhang@unisoc.com>
Date: Mon, 18 Dec 2023 10:44:03 +0800
From: Chunyan Zhang <chunyan.zhang@...soc.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J . Wysocki"
<rafael@...nel.org>
CC: LKML <linux-kernel@...r.kernel.org>, Jing Xia <jing.xia@...soc.com>,
Jing
Xia <jing.xia.mail@...il.com>,
Xuewen Yan <xuewen.yan@...soc.com>, Ke Wang
<ke.wang@...soc.com>,
Chunyan Zhang <zhang.lyra@...il.com>
Subject: [PATCH] class: fix use-after-free in class_register()
From: Jing Xia <jing.xia@...soc.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@...soc.com>
Signed-off-by: Xuewen Yan <xuewen.yan@...soc.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
Powered by blists - more mailing lists