]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke
authorJunrui Luo <moonafterrain@outlook.com>
Fri, 24 Jul 2026 22:33:39 +0000 (23:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 Jul 2026 08:59:47 +0000 (10:59 +0200)
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")
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20260724223342.629168-4-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/fastrpc.c

index 12dcd2e737c31de4a89736fa358a6ea0a06313a1..c75eafe872cc4c50df5dbef4b87ed38bc6134763 100644 (file)
@@ -1305,10 +1305,12 @@ bail:
        }
 
        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)