Skip to content

Commit

Permalink
ipmi: fix use after free in _ipmi_destroy_user()
Browse files Browse the repository at this point in the history
commit a92ce57 upstream.

The intf_free() function frees the "intf" pointer so we cannot
dereference it again on the next line.

Fixes: cbb7986 ("ipmi: Don't allow device module unload when in use")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Message-Id: <Y3M8xa1drZv4CToE@kili>
Cc: <stable@vger.kernel.org> # 5.5+
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
error27 authored and gregkh committed Jan 12, 2023
1 parent 3b49840 commit bfce073
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/char/ipmi/ipmi_msghandler.c
Expand Up @@ -1273,6 +1273,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)) {
/*
Expand Down Expand Up @@ -1334,8 +1335,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)
Expand Down

0 comments on commit bfce073

Please sign in to comment.