From: Tuo Li <islituo@gmail.com>
To: tomas.winkler@intel.com, arnd@arndb.de, gregkh@linuxfoundation.org
Cc: LKML <linux-kernel@vger.kernel.org>, Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [BUG] mei: a possible use-after-free caused by concurrency execution
Date: Thu, 16 Jan 2025 17:26:33 +0800 [thread overview]
Message-ID: <bebacc37-c203-4d1a-a7e5-e51016805e9b@gmail.com> (raw)
Hello,
Our static analysis tool has identified a potential use-after-free caused
by concurrency execution in drivers/misc/mei/main.c.
Consider the following execution scenario:
(The line numbers can be referred to
https://elixir.bootlin.com/linux/v6.12/source/drivers/misc/mei/main.c)
mei_release() //Line 112
cl = file->private_data; //Line 114
mutex_lock(&dev->device_lock); //Line 123
kfree(cl); //Line 149
file->private_data = NULL; //Line 152
mutex_unlock(&dev->device_lock); //Line 154
mei_read() //Line 169
cl = file->private_data; //Line 172
mutex_lock(&dev->device_lock); //Line 184
cb = mei_cl_read_cb(cl, file); //Line 200
cl_dbg(dev, cl, ...); //Line 275
mutex_unlock(&dev->device_lock); //Line 276
If mei_release() and mei_read() can execute concurrently and the execution
order is 114, 172, 123, 149 (free), 152, 154, 184, 200 (use), 275 (use),
276, a possible use-after-free can occur.
Our static analysis tool reports this use-after-free when analyzing Linux
6.12. The tool deduces lock() and unlock() pairs with alias analysis. It
then applies data flow analysis to detect use-after-free across
synchronization points.
I am not quite sure whether this possible use-after-free is real and how to
fix it if it is real.
Any feedback would be appreciated. Thanks!
Sincerely,
Tuo Li
next reply other threads:[~2025-01-16 9:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 9:26 Tuo Li [this message]
2025-01-16 9:51 ` [BUG] mei: a possible use-after-free caused by concurrency execution Greg KH
2025-01-16 10:51 ` Tuo Li
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=bebacc37-c203-4d1a-a7e5-e51016805e9b@gmail.com \
--to=islituo@gmail.com \
--cc=arnd@arndb.de \
--cc=baijiaju1990@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tomas.winkler@intel.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 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.