[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250108044802.3829060-1-quic_lxu5@quicinc.com>
Date: Wed, 8 Jan 2025 10:18:02 +0530
From: Ling Xu <quic_lxu5@...cinc.com>
To: <srinivas.kandagatla@...aro.org>, <amahesh@....qualcomm.com>,
<arnd@...db.de>, <gregkh@...uxfoundation.org>
CC: <quic_kuiw@...cinc.com>, <quic_ekangupt@...cinc.com>,
<linux-arm-msm@...r.kernel.org>, <dri-devel@...ts.freedesktop.org>,
<linux-kernel@...r.kernel.org>, Ling Xu <quic_lxu5@...cinc.com>
Subject: [PATCH] misc: fastrpc: Fix race condition in MUNMAP
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@...cinc.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
Powered by blists - more mailing lists