All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipmi: fix use after free in _ipmi_destroy_user()
@ 2022-11-15 13:17 Dan Carpenter
  2022-11-15 14:15 ` Corey Minyard
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-11-15 13:17 UTC (permalink / raw)
  To: Corey Minyard; +Cc: openipmi-developer, kernel-janitors

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 <error27@gmail.com>
---
 drivers/char/ipmi/ipmi_msghandler.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index f6b8ca6df9b5..186f1fee7534 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -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)
-- 
2.35.1


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

* Re: [PATCH] ipmi: fix use after free in _ipmi_destroy_user()
  2022-11-15 13:17 [PATCH] ipmi: fix use after free in _ipmi_destroy_user() Dan Carpenter
@ 2022-11-15 14:15 ` Corey Minyard
  0 siblings, 0 replies; 2+ messages in thread
From: Corey Minyard @ 2022-11-15 14:15 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: openipmi-developer, kernel-janitors

On Tue, Nov 15, 2022 at 04:17:43PM +0300, Dan Carpenter wrote:
> 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.

> 
> Fixes: cbb79863fc31 ("ipmi: Don't allow device module unload when in use")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>  drivers/char/ipmi/ipmi_msghandler.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index f6b8ca6df9b5..186f1fee7534 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -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)
> -- 
> 2.35.1
> 

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

end of thread, other threads:[~2022-11-15 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 13:17 [PATCH] ipmi: fix use after free in _ipmi_destroy_user() Dan Carpenter
2022-11-15 14:15 ` Corey Minyard

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.