FAILED: patch "[PATCH] misc: fastrpc: Save actual DMA size in fastrpc_map structure" failed to apply to 6.6-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 8b5b456222fd604079b5cf2af1f25ad690f54a25
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025101329-freestyle-unfair-5d44@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8b5b456222fd604079b5cf2af1f25ad690f54a25 Mon Sep 17 00:00:00 2001
From: Ling Xu <[email protected]>
Date: Fri, 12 Sep 2025 14:12:33 +0100
Subject: [PATCH] misc: fastrpc: Save actual DMA size in fastrpc_map structure
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.
drivers/misc/fastrpc.c +18 -9
@@ -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 ; }
Sasha Levin
maintainerPATCH 1/2 misc: fastrpc: Add missing dev_err newlines
From: Ekansh Gupta <[email protected]>
[ Upstream commit a150c68ae6369ea65b786fefd0b8aa0b075c041a ]
Few dev_err calls are missing newlines. This can result in unrelated lines getting appended which might make logs difficult to understand. Add trailing newlines to avoid this.
Stable-dep-of: 8b5b456222fd ("misc: fastrpc: Save actual DMA size in fastrpc_map structure")
--- drivers/misc/fastrpc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/misc/fastrpc.c +5 -5
@@ -325,7 +325,7 @@ static void fastrpc_free_map(struct kref *ref) err =qcom_scm_assign_mem (map->phys, map->size, &src_perms, &perm,1 );if (err) { -dev_err (map->fl->sctx->dev,"Failed to assign memory phys 0x%llx size 0x%llx err %d" , +dev_err (map->fl->sctx->dev,"Failed to assign memory phys 0x%llx size 0x%llx err %d\n" , map->phys, map->size, err);return ; }
@@ -816,7 +816,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, map->attr = attr; err =qcom_scm_assign_mem (map->phys, (u64 )map->size, &src_perms, dst_perms,2 );if (err) { -dev_err (sess->dev,"Failed to assign memory with phys 0x%llx size 0x%llx err %d" , +dev_err (sess->dev,"Failed to assign memory with phys 0x%llx size 0x%llx err %d\n" , map->phys, map->size, err); goto map_err; }
@@ -1222,7 +1222,7 @@ static bool is_session_rejected(struct fastrpc_user *fl, bool unsigned_pd_reques* that does not support unsigned PD offload */ if (!fl->cctx->unsigned_support || !unsigned_pd_request) { -dev_err (&fl->cctx->rpdev->dev,"Error: Untrusted application trying to offload to signed PD" ); +dev_err (&fl->cctx->rpdev->dev,"Error: Untrusted application trying to offload to signed PD\n" );return true; } }
@@ -1286,7 +1286,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, &src_perms, fl->cctx->vmperms, fl->cctx->vmcount);if (err) { -dev_err (fl->sctx->dev,"Failed to assign memory with phys 0x%llx size 0x%llx err %d" , +dev_err (fl->sctx->dev,"Failed to assign memory with phys 0x%llx size 0x%llx err %d\n" , fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); goto err_map; }
@@ -1340,7 +1340,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, (u64 )fl->cctx->remote_heap->size, &src_perms, &dst_perms, 1);if (err) -dev_err (fl->sctx->dev,"Failed to assign memory phys 0x%llx size 0x%llx err %d" , +dev_err (fl->sctx->dev,"Failed to assign memory phys 0x%llx size 0x%llx err %d\n" , fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); } err_map:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/2 misc: fastrpc: Save actual DMA size in fastrpc_map structure
From: Ling Xu <[email protected]>
[ Upstream commit 8b5b456222fd604079b5cf2af1f25ad690f54a25 ]
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.
--- drivers/misc/fastrpc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/misc/fastrpc.c +18 -9
@@ -322,11 +322,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 ; } }
@@ -757,7 +757,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 ;
@@ -797,7 +798,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;
@@ -814,10 +823,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; } }
@@ -2045,7 +2054,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);
@@ -2060,7 +2069,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; }
@@ -2073,7 +2082,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 ; }
Signature · 1 line
2.51.0