ipmi: fix use after free in _ipmi_destroy_user()
Subsystems (2)
PATCH 1/1 ipmi: fix use after free in _ipmi_destroy_user()
The intf_free() function frees the "intf" pointer so we cannot dereference it again on the next line.
Fixes cbb79863fc31 ("ipmi: Don't allow device module unload when in use")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/ipmi/ipmi_msghandler.c +3 -1
@@ -1330,6 +1330,7 @@ static void _ipmi_destroy_user(struct ipmi_user *user)unsigned long flags;struct cmd_rcvr *rcvr;struct cmd_rcvr *rcvrs =NULL ; +struct module *owner;if (!acquire_ipmi_user (user, &i)) {/*
@@ -1392,8 +1393,9 @@ static void _ipmi_destroy_user(struct ipmi_user *user)kfree (rcvr); } + owner = intf->owner;kref_put (&intf->refcount, intf_free); -module_put (intf->owner); +module_put (owner); }int ipmi_destroy_user (struct ipmi_user *user)
Signature · 1 line
2.35.1
Quoted 2 lines · Dan Carpenter
The
intf_free()function frees the "intf" pointer so we cannot dereference it again on the next line.
Thanks. I will request a backport for 5.5 and later.
Quoted 33 lines
Fixes cbb79863fc31 ("ipmi: Don't allow device module unload when in use")Signed-off-by Dan Carpenter <[email protected]>--- drivers/char/ipmi/ipmi_msghandler.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/char/ipmi/ipmi_msghandler.c +3
-1@@ -1330,6 +1330,7 @@ static void _ipmi_destroy_user(struct ipmi_user *user)unsigned long flags;struct cmd_rcvr *rcvr;struct cmd_rcvr *rcvrs =NULL ; +struct module *owner;if (!acquire_ipmi_user (user, &i)) {/* @@ -1392,8 +1393,9 @@ static void _ipmi_destroy_user(struct ipmi_user *user)kfree (rcvr); } + owner = intf->owner;kref_put (&intf->refcount, intf_free); -module_put (intf->owner); +module_put (owner); }int ipmi_destroy_user (struct ipmi_user *user)Signature · 1 line
2.35.1