From: Sangsup Lee <k1rh4.lee@gmail.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Amol Maheshwari <amahesh@qti.qualcomm.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
Sangsup lee <k1rh4.lee@gmail.com>
Subject: [PATCH v2] misc: fastrpc: Fix a Use after-free-bug by race condition
Date: Thu, 23 Mar 2023 10:36:55 +0900 [thread overview]
Message-ID: <20230323013655.366-1-k1rh4.lee@gmail.com> (raw)
From: Sangsup lee <k1rh4.lee@gmail.com>
This patch adds mutex_lock for fixing an Use-after-free bug.
fastrpc_req_munmap_impl can be called concurrently in multi-threded environments.
The buf which is allocated by list_for_each_safe can be used after another thread frees it.
Signed-off-by: Sangsup lee <k1rh4.lee@gmail.com>
---
V1 -> V2: moving the locking to ioctl.
drivers/misc/fastrpc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 93ebd174d848..aa1cf0e9f4ed 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1901,7 +1901,9 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
err = fastrpc_req_mmap(fl, argp);
break;
case FASTRPC_IOCTL_MUNMAP:
+ mutex_lock(&fl->mutex);
err = fastrpc_req_munmap(fl, argp);
+ mutex_unlock(&fl->mutex);
break;
case FASTRPC_IOCTL_MEM_MAP:
err = fastrpc_req_mem_map(fl, argp);
--
2.25.1
next reply other threads:[~2023-03-23 1:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 1:36 Sangsup Lee [this message]
2023-04-27 9:29 ` [PATCH v2] misc: fastrpc: Fix a Use after-free-bug by race condition sangsup lee
2023-04-27 9:52 ` Greg Kroah-Hartman
2023-04-27 11:51 ` sangsup lee
2023-04-27 12:27 ` Greg Kroah-Hartman
2023-04-28 5:00 ` sangsup lee
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=20230323013655.366-1-k1rh4.lee@gmail.com \
--to=k1rh4.lee@gmail.com \
--cc=amahesh@qti.qualcomm.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/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