misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke
PATCH 1/1 misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke
When an invoke is interrupted by a signal, wait_for_completion_interruptible() returns -ERESTARTSYS and fastrpc_internal_invoke() moves every buffer from fl->mmaps onto cctx->invoke_interrupted_mmaps. This list_del()/list_add_tail() walk runs without holding fl->lock, the lock that serialises fl->mmaps in fastrpc_req_mmap() and fastrpc_req_munmap() everywhere else.
Take fl->lock around the move, matching every other fl->mmaps accessor.
--- drivers/misc/fastrpc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/fastrpc.c +2 -0
@@ -1259,10 +1259,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, }if (err == -ERESTARTSYS ) { +spin_lock (&fl->lock);list_for_each_entry_safe (buf, b, &fl->mmaps, node) {list_del (&buf->node);list_add_tail (&buf->node, &fl->cctx->invoke_interrupted_mmaps); } +spin_unlock (&fl->lock); }if (err)
---
base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
change-id: 20260602-fixes-ba3a01f66f34
Best regards,
Signature · 1 line
Junrui Luo <[email protected]>
Quoted 9 lines · Junrui Luo
When an invoke is interrupted by a signal,
wait_for_completion_interruptible()returns-ERESTARTSYSandfastrpc_internal_invoke()moves every buffer fromfl->mmapsontocctx->invoke_interrupted_mmaps. This list_del()/list_add_tail() walk runs without holdingfl->lock, the lock that serialisesfl->mmapsinfastrpc_req_mmap()andfastrpc_req_munmap()everywhere else.Take
fl->lockaround the move, matching every otherfl->mmapsaccessor.
Quoted 8 lines
Fixes 76e8e4ace1ed ("misc: fastrpc: Safekeep mmaps on interrupted invoke")Reported-by Yuhao Jiang <[email protected]>Signed-off-by Junrui Luo <[email protected]>--- drivers/misc/fastrpc.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 1 line
Signature · 2 lines
With best wishes Dmitry
Quoted 8 lines · Junrui Luo
When an invoke is interrupted by a signal,
wait_for_completion_interruptible()returns-ERESTARTSYSandfastrpc_internal_invoke()moves every buffer fromfl->mmapsontocctx->invoke_interrupted_mmaps. This list_del()/list_add_tail() walk runs without holdingfl->lock, the lock that serialisesfl->mmapsinfastrpc_req_mmap()andfastrpc_req_munmap()everywhere else.[...]
Applied, thanks!
[1/1] misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke
commit: fbb084ef5f984af90aa56fa063d278a54e677cf9
Best regards,
Signature · 1 line
Srinivas Kandagatla <[email protected]>