From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B88AFC54EF1 for ; Wed, 4 Jan 2023 16:22:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235020AbjADQWP (ORCPT ); Wed, 4 Jan 2023 11:22:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239617AbjADQVf (ORCPT ); Wed, 4 Jan 2023 11:21:35 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94257A45E for ; Wed, 4 Jan 2023 08:21:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4A523B81733 for ; Wed, 4 Jan 2023 16:21:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B070CC433D2; Wed, 4 Jan 2023 16:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672849292; bh=WxSrhrpqyDeqQwktNFOhI4EkwNUo4eNlp4LP9pd2r+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZcX6MXh3wE93Iw69xV99pe0GSCZH4znC9SxNyiXSHcFhP4ygRAuoistDJbyrdNJWJ JYVltV1+YoSF/fG01wuHDfMvxti9QfUoeaCXne/UQXC8oJjgEV92+t9cR18mT3aNK+ p2xyWIP7ggWaFyl4oY58YhQ1y0YwJcslR84dt9ko= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Corey Minyard Subject: [PATCH 6.0 098/177] ipmi: fix use after free in _ipmi_destroy_user() Date: Wed, 4 Jan 2023 17:06:29 +0100 Message-Id: <20230104160510.604935743@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230104160507.635888536@linuxfoundation.org> References: <20230104160507.635888536@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter commit a92ce570c81dc0feaeb12a429b4bc65686d17967 upstream. 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 Message-Id: Cc: # 5.5+ Signed-off-by: Corey Minyard Signed-off-by: Greg Kroah-Hartman --- drivers/char/ipmi/ipmi_msghandler.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -1336,6 +1336,7 @@ static void _ipmi_destroy_user(struct ip unsigned long flags; struct cmd_rcvr *rcvr; struct cmd_rcvr *rcvrs = NULL; + struct module *owner; if (!acquire_ipmi_user(user, &i)) { /* @@ -1398,8 +1399,9 @@ static void _ipmi_destroy_user(struct ip 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)