public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: korantwork@gmail.com
To: ardb@kernel.org, sudeep.holla@arm.com, cristian.marussi@arm.com
Cc: linux-kernel@vger.kernel.org, Xinghui Li <korantli@tencent.com>,
	loydlv <loydlv@tencent.com>
Subject: [PATCH] firmware: fix one UAF issue
Date: Thu, 12 Jan 2023 15:05:03 +0800	[thread overview]
Message-ID: <20230112070503.817076-1-korantwork@gmail.com> (raw)

From: Xinghui Li <korantli@tencent.com>

There could be the use after free issue in dmi_sysfs_register_handle.
During handling specializations process, the entry->child could be
free if the error occurs. However, it will be kobject_put after free.
So, we set the entry->child to NULL to avoid above case.

Reported-by: loydlv <loydlv@tencent.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
---
 drivers/firmware/dmi-sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
index 66727ad3361b..dd4ff5f7e200 100644
--- a/drivers/firmware/dmi-sysfs.c
+++ b/drivers/firmware/dmi-sysfs.c
@@ -470,6 +470,7 @@ static int dmi_system_event_log(struct dmi_sysfs_entry *entry)
 	kobject_del(entry->child);
 out_free:
 	kfree(entry->child);
+	entry->child = NULL;
 	return ret;
 }
 
-- 
2.31.1


                 reply	other threads:[~2023-01-12  7:05 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=20230112070503.817076-1-korantwork@gmail.com \
    --to=korantwork@gmail.com \
    --cc=ardb@kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=korantli@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loydlv@tencent.com \
    --cc=sudeep.holla@arm.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