* [PATCH] misc: fastrpc: Fix race condition in MUNMAP
@ 2025-01-08 4:48 Ling Xu
2025-01-08 6:07 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Ling Xu @ 2025-01-08 4:48 UTC (permalink / raw)
To: srinivas.kandagatla, amahesh, arnd, gregkh
Cc: quic_kuiw, quic_ekangupt, linux-arm-msm, dri-devel, linux-kernel,
Ling Xu
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);
break;
case FASTRPC_IOCTL_MEM_MAP:
err = fastrpc_req_mem_map(fl, argp);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] misc: fastrpc: Fix race condition in MUNMAP
2025-01-08 4:48 [PATCH] misc: fastrpc: Fix race condition in MUNMAP Ling Xu
@ 2025-01-08 6:07 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2025-01-08 6:07 UTC (permalink / raw)
To: Ling Xu
Cc: srinivas.kandagatla, amahesh, arnd, quic_kuiw, quic_ekangupt,
linux-arm-msm, dri-devel, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-08 6:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 4:48 [PATCH] misc: fastrpc: Fix race condition in MUNMAP Ling Xu
2025-01-08 6:07 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox