linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Add missing fixes to FastRPC driver
@ 2025-08-07 10:04 Ling Xu
  2025-08-07 10:04 ` [PATCH v3 1/4] misc: fastrpc: Save actual DMA size in fastrpc_map structure Ling Xu
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ling Xu @ 2025-08-07 10:04 UTC (permalink / raw)
  To: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa
  Cc: quic_kuiw, ekansh.gupta, dri-devel, linux-arm-msm, linux-media,
	linaro-mm-sig, linux-kernel, Ling Xu

This patch series adds the listed bug fixes that have been missing
in upstream fastRPC driver.
- Store actual size of map and check it against the user passed size.
- Consider map buf for map lookup.
- Fix possible map leak in fastrpc_put_args.
- Skip refcount increment for DMA handles.
Patch [v2]: https://lore.kernel.org/linux-arm-msm/20250806115114.688814-1-quic_lxu5@quicinc.com/

Changes in v3:
  - Remove the unused line.
Changes in v2:
  - Fix possible map leak in fastrpc_put_args.
  - Remove take_ref argument.

Ling Xu (4):
  misc: fastrpc: Save actual DMA size in fastrpc_map structure
  misc: fastrpc: Fix fastrpc_map_lookup operation
  misc: fastrpc: fix possible map leak in fastrpc_put_args
  misc: fastrpc: Skip reference for DMA handles

 drivers/misc/fastrpc.c | 89 +++++++++++++++++++++++++++---------------
 1 file changed, 58 insertions(+), 31 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/4] misc: fastrpc: Save actual DMA size in fastrpc_map structure
  2025-08-07 10:04 [PATCH v3 0/4] Add missing fixes to FastRPC driver Ling Xu
@ 2025-08-07 10:04 ` Ling Xu
  2025-08-07 10:04 ` [PATCH v3 2/4] misc: fastrpc: Fix fastrpc_map_lookup operation Ling Xu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ling Xu @ 2025-08-07 10:04 UTC (permalink / raw)
  To: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa
  Cc: quic_kuiw, ekansh.gupta, dri-devel, linux-arm-msm, linux-media,
	linaro-mm-sig, linux-kernel, Ling Xu, stable, Dmitry Baryshkov

For user passed fd buffer, map is created using DMA calls. The
map related information is stored in fastrpc_map structure. The
actual DMA size is not stored in the structure. Store the actual
size of buffer and check it against the user passed size.

Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
Cc: stable@kernel.org
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
---
 drivers/misc/fastrpc.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 53e88a1bc430..52571916acd4 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -323,11 +323,11 @@ static void fastrpc_free_map(struct kref *ref)
 
 			perm.vmid = QCOM_SCM_VMID_HLOS;
 			perm.perm = QCOM_SCM_PERM_RWX;
-			err = qcom_scm_assign_mem(map->phys, map->size,
+			err = qcom_scm_assign_mem(map->phys, map->len,
 				&src_perms, &perm, 1);
 			if (err) {
 				dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d\n",
-						map->phys, map->size, err);
+						map->phys, map->len, err);
 				return;
 			}
 		}
@@ -758,7 +758,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 	struct fastrpc_session_ctx *sess = fl->sctx;
 	struct fastrpc_map *map = NULL;
 	struct sg_table *table;
-	int err = 0;
+	struct scatterlist *sgl = NULL;
+	int err = 0, sgl_index = 0;
 
 	if (!fastrpc_map_lookup(fl, fd, ppmap, true))
 		return 0;
@@ -798,7 +799,15 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 		map->phys = sg_dma_address(map->table->sgl);
 		map->phys += ((u64)fl->sctx->sid << 32);
 	}
-	map->size = len;
+	for_each_sg(map->table->sgl, sgl, map->table->nents,
+		sgl_index)
+		map->size += sg_dma_len(sgl);
+	if (len > map->size) {
+		dev_dbg(sess->dev, "Bad size passed len 0x%llx map size 0x%llx\n",
+				len, map->size);
+		err = -EINVAL;
+		goto map_err;
+	}
 	map->va = sg_virt(map->table->sgl);
 	map->len = len;
 
@@ -815,10 +824,10 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 		dst_perms[1].vmid = fl->cctx->vmperms[0].vmid;
 		dst_perms[1].perm = QCOM_SCM_PERM_RWX;
 		map->attr = attr;
-		err = qcom_scm_assign_mem(map->phys, (u64)map->size, &src_perms, dst_perms, 2);
+		err = qcom_scm_assign_mem(map->phys, (u64)map->len, &src_perms, dst_perms, 2);
 		if (err) {
 			dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d\n",
-					map->phys, map->size, err);
+					map->phys, map->len, err);
 			goto map_err;
 		}
 	}
@@ -2046,7 +2055,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
 	args[0].length = sizeof(req_msg);
 
 	pages.addr = map->phys;
-	pages.size = map->size;
+	pages.size = map->len;
 
 	args[1].ptr = (u64) (uintptr_t) &pages;
 	args[1].length = sizeof(pages);
@@ -2061,7 +2070,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
 	err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, &args[0]);
 	if (err) {
 		dev_err(dev, "mem mmap error, fd %d, vaddr %llx, size %lld\n",
-			req.fd, req.vaddrin, map->size);
+			req.fd, req.vaddrin, map->len);
 		goto err_invoke;
 	}
 
@@ -2074,7 +2083,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
 	if (copy_to_user((void __user *)argp, &req, sizeof(req))) {
 		/* unmap the memory and release the buffer */
 		req_unmap.vaddr = (uintptr_t) rsp_msg.vaddr;
-		req_unmap.length = map->size;
+		req_unmap.length = map->len;
 		fastrpc_req_mem_unmap_impl(fl, &req_unmap);
 		return -EFAULT;
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/4] misc: fastrpc: Fix fastrpc_map_lookup operation
  2025-08-07 10:04 [PATCH v3 0/4] Add missing fixes to FastRPC driver Ling Xu
  2025-08-07 10:04 ` [PATCH v3 1/4] misc: fastrpc: Save actual DMA size in fastrpc_map structure Ling Xu
@ 2025-08-07 10:04 ` Ling Xu
  2025-08-14  7:04   ` Dmitry Baryshkov
  2025-08-07 10:04 ` [PATCH v3 3/4] misc: fastrpc: fix possible map leak in fastrpc_put_args Ling Xu
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Ling Xu @ 2025-08-07 10:04 UTC (permalink / raw)
  To: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa
  Cc: quic_kuiw, ekansh.gupta, dri-devel, linux-arm-msm, linux-media,
	linaro-mm-sig, linux-kernel, Ling Xu, stable

Fastrpc driver creates maps for user allocated fd buffers. Before
creating a new map, the map list is checked for any already existing
maps using map fd. Checking with just map fd is not sufficient as the
user can pass offsetted buffer with less size when the map is created
and then a larger size the next time which could result in memory
issues. Check for dma_buf object also when looking up for the map.

Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
Cc: stable@kernel.org
Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
---
 drivers/misc/fastrpc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 52571916acd4..1815b1e0c607 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -367,11 +367,16 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
 {
 	struct fastrpc_session_ctx *sess = fl->sctx;
 	struct fastrpc_map *map = NULL;
+	struct dma_buf *buf;
 	int ret = -ENOENT;
 
+	buf = dma_buf_get(fd);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
 	spin_lock(&fl->lock);
 	list_for_each_entry(map, &fl->maps, node) {
-		if (map->fd != fd)
+		if (map->fd != fd || map->buf != buf)
 			continue;
 
 		if (take_ref) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/4] misc: fastrpc: fix possible map leak in fastrpc_put_args
  2025-08-07 10:04 [PATCH v3 0/4] Add missing fixes to FastRPC driver Ling Xu
  2025-08-07 10:04 ` [PATCH v3 1/4] misc: fastrpc: Save actual DMA size in fastrpc_map structure Ling Xu
  2025-08-07 10:04 ` [PATCH v3 2/4] misc: fastrpc: Fix fastrpc_map_lookup operation Ling Xu
@ 2025-08-07 10:04 ` Ling Xu
  2025-08-14  7:02   ` Dmitry Baryshkov
  2025-08-07 10:04 ` [PATCH v3 4/4] misc: fastrpc: Skip reference for DMA handles Ling Xu
  2025-08-19 11:31 ` [PATCH v3 0/4] Add missing fixes to FastRPC driver Srinivas Kandagatla
  4 siblings, 1 reply; 9+ messages in thread
From: Ling Xu @ 2025-08-07 10:04 UTC (permalink / raw)
  To: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa
  Cc: quic_kuiw, ekansh.gupta, dri-devel, linux-arm-msm, linux-media,
	linaro-mm-sig, linux-kernel, Ling Xu, stable

copy_to_user() failure would cause an early return without cleaning up
the fdlist, which has been updated by the DSP. This could lead to map
leak. Fix this by redirecting to a cleanup path on failure, ensuring
that all mapped buffers are properly released before returning.

Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
Cc: stable@kernel.org
Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
---
 drivers/misc/fastrpc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 1815b1e0c607..d950a179bff8 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1085,6 +1085,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 	struct fastrpc_phy_page *pages;
 	u64 *fdlist;
 	int i, inbufs, outbufs, handles;
+	int ret = 0;
 
 	inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
 	outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
@@ -1100,14 +1101,17 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 			u64 len = rpra[i].buf.len;
 
 			if (!kernel) {
-				if (copy_to_user((void __user *)dst, src, len))
-					return -EFAULT;
+				if (copy_to_user((void __user *)dst, src, len)) {
+					ret = -EFAULT;
+					goto cleanup_fdlist;
+				}
 			} else {
 				memcpy(dst, src, len);
 			}
 		}
 	}
 
+cleanup_fdlist:
 	/* Clean up fdlist which is updated by DSP */
 	for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
 		if (!fdlist[i])
@@ -1116,7 +1120,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 			fastrpc_map_put(mmap);
 	}
 
-	return 0;
+	return ret;
 }
 
 static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/4] misc: fastrpc: Skip reference for DMA handles
  2025-08-07 10:04 [PATCH v3 0/4] Add missing fixes to FastRPC driver Ling Xu
                   ` (2 preceding siblings ...)
  2025-08-07 10:04 ` [PATCH v3 3/4] misc: fastrpc: fix possible map leak in fastrpc_put_args Ling Xu
@ 2025-08-07 10:04 ` Ling Xu
  2025-08-14  7:03   ` Dmitry Baryshkov
  2025-08-19 11:31 ` [PATCH v3 0/4] Add missing fixes to FastRPC driver Srinivas Kandagatla
  4 siblings, 1 reply; 9+ messages in thread
From: Ling Xu @ 2025-08-07 10:04 UTC (permalink / raw)
  To: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa
  Cc: quic_kuiw, ekansh.gupta, dri-devel, linux-arm-msm, linux-media,
	linaro-mm-sig, linux-kernel, Ling Xu, stable

If multiple dma handles are passed with same fd over a remote call
the kernel driver takes a reference and expects that put for the
map will be called as many times to free the map. But DSP only
updates the fd one time in the fd list when the DSP refcount
goes to zero and hence kernel make put call only once for the
fd. This can cause SMMU fault issue as the same fd can be used
in future for some other call.

Fixes: 35a82b87135d ("misc: fastrpc: Add dma handle implementation")
Cc: stable@kernel.org
Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
---
 drivers/misc/fastrpc.c | 45 +++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index d950a179bff8..7eec907ed454 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -363,9 +363,8 @@ static int fastrpc_map_get(struct fastrpc_map *map)
 
 
 static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
-			    struct fastrpc_map **ppmap, bool take_ref)
+			    struct fastrpc_map **ppmap)
 {
-	struct fastrpc_session_ctx *sess = fl->sctx;
 	struct fastrpc_map *map = NULL;
 	struct dma_buf *buf;
 	int ret = -ENOENT;
@@ -379,15 +378,6 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
 		if (map->fd != fd || map->buf != buf)
 			continue;
 
-		if (take_ref) {
-			ret = fastrpc_map_get(map);
-			if (ret) {
-				dev_dbg(sess->dev, "%s: Failed to get map fd=%d ret=%d\n",
-					__func__, fd, ret);
-				break;
-			}
-		}
-
 		*ppmap = map;
 		ret = 0;
 		break;
@@ -757,7 +747,7 @@ static const struct dma_buf_ops fastrpc_dma_buf_ops = {
 	.release = fastrpc_release,
 };
 
-static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
+static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
 			      u64 len, u32 attr, struct fastrpc_map **ppmap)
 {
 	struct fastrpc_session_ctx *sess = fl->sctx;
@@ -766,9 +756,6 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 	struct scatterlist *sgl = NULL;
 	int err = 0, sgl_index = 0;
 
-	if (!fastrpc_map_lookup(fl, fd, ppmap, true))
-		return 0;
-
 	map = kzalloc(sizeof(*map), GFP_KERNEL);
 	if (!map)
 		return -ENOMEM;
@@ -853,6 +840,24 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 	return err;
 }
 
+static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
+			      u64 len, u32 attr, struct fastrpc_map **ppmap)
+{
+	struct fastrpc_session_ctx *sess = fl->sctx;
+	int err = 0;
+
+	if (!fastrpc_map_lookup(fl, fd, ppmap)) {
+		if (!fastrpc_map_get(*ppmap))
+			return 0;
+		dev_dbg(sess->dev, "%s: Failed to get map fd=%d\n",
+			__func__, fd);
+	}
+
+	err = fastrpc_map_attach(fl, fd, len, attr, ppmap);
+
+	return err;
+}
+
 /*
  * Fastrpc payload buffer with metadata looks like:
  *
@@ -925,8 +930,12 @@ static int fastrpc_create_maps(struct fastrpc_invoke_ctx *ctx)
 		    ctx->args[i].length == 0)
 			continue;
 
-		err = fastrpc_map_create(ctx->fl, ctx->args[i].fd,
-			 ctx->args[i].length, ctx->args[i].attr, &ctx->maps[i]);
+		if (i < ctx->nbufs)
+			err = fastrpc_map_create(ctx->fl, ctx->args[i].fd,
+				 ctx->args[i].length, ctx->args[i].attr, &ctx->maps[i]);
+		else
+			err = fastrpc_map_attach(ctx->fl, ctx->args[i].fd,
+				 ctx->args[i].length, ctx->args[i].attr, &ctx->maps[i]);
 		if (err) {
 			dev_err(dev, "Error Creating map %d\n", err);
 			return -EINVAL;
@@ -1116,7 +1125,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 	for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
 		if (!fdlist[i])
 			break;
-		if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap, false))
+		if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap))
 			fastrpc_map_put(mmap);
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/4] misc: fastrpc: fix possible map leak in fastrpc_put_args
  2025-08-07 10:04 ` [PATCH v3 3/4] misc: fastrpc: fix possible map leak in fastrpc_put_args Ling Xu
@ 2025-08-14  7:02   ` Dmitry Baryshkov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Baryshkov @ 2025-08-14  7:02 UTC (permalink / raw)
  To: Ling Xu
  Cc: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa, quic_kuiw, ekansh.gupta,
	dri-devel, linux-arm-msm, linux-media, linaro-mm-sig,
	linux-kernel, stable

On Thu, Aug 07, 2025 at 03:34:19PM +0530, Ling Xu wrote:
> copy_to_user() failure would cause an early return without cleaning up
> the fdlist, which has been updated by the DSP. This could lead to map
> leak. Fix this by redirecting to a cleanup path on failure, ensuring
> that all mapped buffers are properly released before returning.
> 
> Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
> Cc: stable@kernel.org
> Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
> Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
> Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
> ---
>  drivers/misc/fastrpc.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 4/4] misc: fastrpc: Skip reference for DMA handles
  2025-08-07 10:04 ` [PATCH v3 4/4] misc: fastrpc: Skip reference for DMA handles Ling Xu
@ 2025-08-14  7:03   ` Dmitry Baryshkov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Baryshkov @ 2025-08-14  7:03 UTC (permalink / raw)
  To: Ling Xu
  Cc: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa, quic_kuiw, ekansh.gupta,
	dri-devel, linux-arm-msm, linux-media, linaro-mm-sig,
	linux-kernel, stable

On Thu, Aug 07, 2025 at 03:34:20PM +0530, Ling Xu wrote:
> If multiple dma handles are passed with same fd over a remote call
> the kernel driver takes a reference and expects that put for the
> map will be called as many times to free the map. But DSP only
> updates the fd one time in the fd list when the DSP refcount
> goes to zero and hence kernel make put call only once for the
> fd. This can cause SMMU fault issue as the same fd can be used
> in future for some other call.
> 
> Fixes: 35a82b87135d ("misc: fastrpc: Add dma handle implementation")
> Cc: stable@kernel.org
> Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
> Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
> Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
> ---
>  drivers/misc/fastrpc.c | 45 +++++++++++++++++++++++++-----------------
>  1 file changed, 27 insertions(+), 18 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/4] misc: fastrpc: Fix fastrpc_map_lookup operation
  2025-08-07 10:04 ` [PATCH v3 2/4] misc: fastrpc: Fix fastrpc_map_lookup operation Ling Xu
@ 2025-08-14  7:04   ` Dmitry Baryshkov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Baryshkov @ 2025-08-14  7:04 UTC (permalink / raw)
  To: Ling Xu
  Cc: srini, amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa, quic_kuiw, ekansh.gupta,
	dri-devel, linux-arm-msm, linux-media, linaro-mm-sig,
	linux-kernel, stable

On Thu, Aug 07, 2025 at 03:34:18PM +0530, Ling Xu wrote:
> Fastrpc driver creates maps for user allocated fd buffers. Before
> creating a new map, the map list is checked for any already existing
> maps using map fd. Checking with just map fd is not sufficient as the
> user can pass offsetted buffer with less size when the map is created
> and then a larger size the next time which could result in memory
> issues. Check for dma_buf object also when looking up for the map.
> 
> Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
> Cc: stable@kernel.org
> Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
> Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
> Signed-off-by: Ling Xu <quic_lxu5@quicinc.com>
> ---
>  drivers/misc/fastrpc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 0/4] Add missing fixes to FastRPC driver
  2025-08-07 10:04 [PATCH v3 0/4] Add missing fixes to FastRPC driver Ling Xu
                   ` (3 preceding siblings ...)
  2025-08-07 10:04 ` [PATCH v3 4/4] misc: fastrpc: Skip reference for DMA handles Ling Xu
@ 2025-08-19 11:31 ` Srinivas Kandagatla
  4 siblings, 0 replies; 9+ messages in thread
From: Srinivas Kandagatla @ 2025-08-19 11:31 UTC (permalink / raw)
  To: amahesh, arnd, gregkh, sumit.semwal, christian.koenig,
	thierry.escande, quic_vgattupa, Ling Xu
  Cc: quic_kuiw, ekansh.gupta, dri-devel, linux-arm-msm, linux-media,
	linaro-mm-sig, linux-kernel


On Thu, 07 Aug 2025 15:34:16 +0530, Ling Xu wrote:
> This patch series adds the listed bug fixes that have been missing
> in upstream fastRPC driver.
> - Store actual size of map and check it against the user passed size.
> - Consider map buf for map lookup.
> - Fix possible map leak in fastrpc_put_args.
> - Skip refcount increment for DMA handles.
> Patch [v2]: https://lore.kernel.org/linux-arm-msm/20250806115114.688814-1-quic_lxu5@quicinc.com/
> 
> [...]

Applied, thanks!

[1/4] misc: fastrpc: Save actual DMA size in fastrpc_map structure
      commit: 69fb36431c5e1bd09981f931b3030296cdc6c7b5
[2/4] misc: fastrpc: Fix fastrpc_map_lookup operation
      commit: a8b2a851e3f9a8497ff857d9a152659988612af4
[3/4] misc: fastrpc: fix possible map leak in fastrpc_put_args
      commit: ba7a9771f1e3a622d51f95a1f5a4ff9958ca5c64
[4/4] misc: fastrpc: Skip reference for DMA handles
      commit: cbf27dd4e98e5a3b71dbe89972461ce5bb4c188c

Best regards,
-- 
Srinivas Kandagatla <srini@kernel.org>


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-08-19 11:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 10:04 [PATCH v3 0/4] Add missing fixes to FastRPC driver Ling Xu
2025-08-07 10:04 ` [PATCH v3 1/4] misc: fastrpc: Save actual DMA size in fastrpc_map structure Ling Xu
2025-08-07 10:04 ` [PATCH v3 2/4] misc: fastrpc: Fix fastrpc_map_lookup operation Ling Xu
2025-08-14  7:04   ` Dmitry Baryshkov
2025-08-07 10:04 ` [PATCH v3 3/4] misc: fastrpc: fix possible map leak in fastrpc_put_args Ling Xu
2025-08-14  7:02   ` Dmitry Baryshkov
2025-08-07 10:04 ` [PATCH v3 4/4] misc: fastrpc: Skip reference for DMA handles Ling Xu
2025-08-14  7:03   ` Dmitry Baryshkov
2025-08-19 11:31 ` [PATCH v3 0/4] Add missing fixes to FastRPC driver Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).