From: Greg KH <gregkh@linuxfoundation.org>
To: Ling Xu <quic_lxu5@quicinc.com>
Cc: srinivas.kandagatla@linaro.org, amahesh@qti.qualcomm.com,
arnd@arndb.de, quic_kuiw@quicinc.com, quic_ekangupt@quicinc.com,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] misc: fastrpc: Fix race condition in MUNMAP
Date: Wed, 8 Jan 2025 07:07:59 +0100 [thread overview]
Message-ID: <2025010807-babble-album-7bfd@gregkh> (raw)
In-Reply-To: <20250108044802.3829060-1-quic_lxu5@quicinc.com>
On Wed, Jan 08, 2025 at 10:18:02AM +0530, Ling Xu wrote:
> fastrpc_req_munmap involves two steps to unmap memory, first to locates
> a matching fastrpc buf in the list and second is to send request to DSP
> to unmap. There is a potential race condition between two operations
> which can lead to user-after-free scenario.
> Lock unmap request to avoid use-after-free.
>
> Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
> ---
> drivers/misc/fastrpc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 7b7a22c91fe4..9ad092d3a705 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -2117,7 +2117,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);
Why do you grab a mutex here when this function grabs the spinlock too?
This feels like an odd fix, shouldn't the lock be in the function at the
very least?
thanks,
greg k-h
prev parent reply other threads:[~2025-01-08 6:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 4:48 [PATCH] misc: fastrpc: Fix race condition in MUNMAP Ling Xu
2025-01-08 6:07 ` Greg KH [this message]
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=2025010807-babble-album-7bfd@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=amahesh@qti.qualcomm.com \
--cc=arnd@arndb.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_ekangupt@quicinc.com \
--cc=quic_kuiw@quicinc.com \
--cc=quic_lxu5@quicinc.com \
--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