misc: fastrpc: avoid duplicate DMA mappings in fastrpc_create_maps()#774
misc: fastrpc: avoid duplicate DMA mappings in fastrpc_create_maps()#774Jianping-Li wants to merge 2 commits into
Conversation
fastrpc_map_lookup returns a raw pointer after releasing fl->lock. The caller fastrpc_map_create then calls fastrpc_map_get (kref_get_unless_zero) on this unprotected pointer. A concurrent MEM_UNMAP can free the map between the lock release and the kref operation, resulting in a use-after-free on the freed slab object. Restore the take_ref parameter to fastrpc_map_lookup so the reference is acquired atomically under fl->lock before the pointer is exposed to the caller. Link: https://lore.kernel.org/all/20260530204528.116920-5-srini@kernel.org/ Fixes: 10df039 ("misc: fastrpc: Skip reference for DMA handles") Cc: stable@vger.kernel.org Signed-off-by: Zhenghang Xiao <kipreyyy@gmail.com> Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
…te_maps() fastrpc_create_maps() performs map lookup only for buffer arguments (i < ctx->nbufs) via fastrpc_map_create(). For arguments beyond this range, no lookup is performed, which can result in duplicate DMA mappings for the same file descriptor. Additionally, if the same file descriptor is passed multiple times within a single invocation, performing lookups with reference counting would increment the reference multiple times, while fastrpc_put_args() would release it only once, leading to an imbalanced reference count. Fix this by allowing fastrpc_map_create() to control whether the lookup should take a reference. For arguments beyond ctx->nbufs, the lookup is performed without taking a reference, ensuring that existing mappings are reused without introducing duplicate DMA mappings or reference count imbalance. Link: https://lore.kernel.org/all/20260625080832.17477-1-jianping.li@oss.qualcomm.com/ Fixes: 10df039 ("misc: fastrpc: Skip reference for DMA handles") Cc: stable@kernel.org Signed-off-by: Jianping Li <jianping.li@oss.qualcomm.com>
|
Merge Check Failed: No Change Task Found No associated change tasks found for CR 4490320 on any of the following entities: Entities:
CR: 4490320 Please ensure the CR has a change task associated with at least one of the entities for this branch. |
1 similar comment
|
Merge Check Failed: No Change Task Found No associated change tasks found for CR 4490320 on any of the following entities: Entities:
CR: 4490320 Please ensure the CR has a change task associated with at least one of the entities for this branch. |
PR #774 — validate-patchPR: #774
Final Summary
|
PR #774 — checker-log-analyzerPR: #774
Detailed report: Full report
|
fastrpc_create_maps() performs map lookup only for buffer arguments (i < ctx->nbufs) via fastrpc_map_create(). For
arguments beyond this range, no lookup is performed, which can result in duplicate DMA mappings for the same file descriptor.
Additionally, if the same file descriptor is passed multiple times within a single invocation, performing lookups with
reference counting would increment the reference multiple times, while fastrpc_put_args() would release it only once,
leading to an imbalanced reference count.
Fix this by allowing fastrpc_map_create() to control whether the lookup should take a reference. For arguments beyond
ctx->nbufs, the lookup is performed without taking a reference, ensuring that existing mappings are reused without introducing duplicate DMA mappings or reference count imbalance.
CRs-Fixed: 4490320