Skip to contentSkip to conversation

misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke

PATCH Applied Junrui Luo 3 participants 3 messages Jun 2 – Jul 1

Subsystems (4)
lore
Share & tools
lore

Junrui Luo

author
#0 lore raw

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.

Fixes 76e8e4ace1ed ("misc: fastrpc: Safekeep mmaps on interrupted invoke")
---
 drivers/misc/fastrpc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/misc/fastrpc.c +2 -0
index 1080f9acf70a..1601c9667d0b 100644
@@ -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]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Junrui Luo

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.

Quoted 8 lines
Fixes 76e8e4ace1ed ("misc: fastrpc: Safekeep mmaps on interrupted invoke")
---
 drivers/misc/fastrpc.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 1 line
Signature · 2 lines
With best wishes
Dmitry
maintainer Applied
#2 lore raw
In reply to Junrui Luo
Quoted 8 lines · Junrui Luo

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.

[...]

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]>