Skip to content

Commit 911f43e

Browse files
dmantipovsmb49
authored andcommitted
module: ensure that kobject_put() is safe for module type kobjects
BugLink: https://bugs.launchpad.net/bugs/2115252 commit a6aeb73 upstream. In 'lookup_or_create_module_kobject()', an internal kobject is created using 'module_ktype'. So call to 'kobject_put()' on error handling path causes an attempt to use an uninitialized completion pointer in 'module_kobject_release()'. In this scenario, we just want to release kobject without an extra synchronization required for a regular module unloading process, so adding an extra check whether 'complete()' is actually required makes 'kobject_put()' safe. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=7fb8a372e1f6add936dd Fixes: 942e443 ("module: Fix mod->mkobj.kobj potentially freed too early") Cc: [email protected] Suggested-by: Petr Pavlu <[email protected]> Signed-off-by: Dmitry Antipov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Pavlu <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> CVE-2025-37995 Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 286699e commit 911f43e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/params.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,9 @@ struct kset *module_kset;
949949
static void module_kobj_release(struct kobject *kobj)
950950
{
951951
struct module_kobject *mk = to_module_kobject(kobj);
952-
complete(mk->kobj_completion);
952+
953+
if (mk->kobj_completion)
954+
complete(mk->kobj_completion);
953955
}
954956

955957
const struct kobj_type module_ktype = {

0 commit comments

Comments
 (0)