From: Russ Weight <russell.h.weight@intel.com>
To: mcgrof@kernel.org, rafael@kernel.org, linux-kernel@vger.kernel.org
Cc: trix@redhat.com, lgoncalv@redhat.com,
matthew.gerlach@linux.intel.com,
basheer.ahmed.muddebihal@intel.com, tianfei.zhang@intel.com,
Russ Weight <russell.h.weight@intel.com>,
kernel test robot <oliver.sang@intel.com>
Subject: [PATCH v1 1/1] firmware_loader: Fix use-after-free during unregister
Date: Tue, 2 Aug 2022 13:09:42 -0700 [thread overview]
Message-ID: <20220802200942.98149-1-russell.h.weight@intel.com> (raw)
In the following code within firmware_upload_unregister(), the call
to device_unregister() results in the dev_release function freeing the
fw_upload_priv structure before it is dereferenced for the call to
module_put():
device_unregister(&fw_sysfs->dev);
module_put(fw_upload_priv->module);
This is fixed by copying fw_upload_priv->module to a local variable
before calling device_unregister() and then using the local variable
for the call to module_put().
Reported-by: kernel test robot <oliver.sang@intel.com>
Fixes: 97730bbb242c (firmware_loader: Add firmware-upload support)
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
---
drivers/base/firmware_loader/sysfs_upload.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/firmware_loader/sysfs_upload.c b/drivers/base/firmware_loader/sysfs_upload.c
index 87044d52322a..63e15bddd80c 100644
--- a/drivers/base/firmware_loader/sysfs_upload.c
+++ b/drivers/base/firmware_loader/sysfs_upload.c
@@ -377,6 +377,7 @@ void firmware_upload_unregister(struct fw_upload *fw_upload)
{
struct fw_sysfs *fw_sysfs = fw_upload->priv;
struct fw_upload_priv *fw_upload_priv = fw_sysfs->fw_upload_priv;
+ struct module *module = fw_upload_priv->module;
mutex_lock(&fw_upload_priv->lock);
if (fw_upload_priv->progress == FW_UPLOAD_PROG_IDLE) {
@@ -392,6 +393,6 @@ void firmware_upload_unregister(struct fw_upload *fw_upload)
unregister:
device_unregister(&fw_sysfs->dev);
- module_put(fw_upload_priv->module);
+ module_put(module);
}
EXPORT_SYMBOL_GPL(firmware_upload_unregister);
--
2.25.1
reply other threads:[~2022-08-02 20:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220802200942.98149-1-russell.h.weight@intel.com \
--to=russell.h.weight@intel.com \
--cc=basheer.ahmed.muddebihal@intel.com \
--cc=lgoncalv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.gerlach@linux.intel.com \
--cc=mcgrof@kernel.org \
--cc=oliver.sang@intel.com \
--cc=rafael@kernel.org \
--cc=tianfei.zhang@intel.com \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®