Skip to content

Commit

Permalink
misc: fastrpc: reject new invocations during device removal
Browse files Browse the repository at this point in the history
commit 4624840 upstream.

The channel's rpmsg object allows new invocations to be made. After old
invocations are already interrupted, the driver shouldn't try to invoke
anymore. Invalidating the rpmsg at the end of the driver removal
function makes it easy to cause a race condition in userspace. Even
closing a file descriptor before the driver finishes its cleanup can
cause an invocation via fastrpc_release_current_dsp_process() and
subsequent timeout.

Invalidate the channel before the invocations are interrupted to make
sure that no invocations can be created to hang after the device closes.

Fixes: c68cfb7 ("misc: fastrpc: Add support for context Invoke method")
Cc: stable <stable@kernel.org>
Signed-off-by: Richard Acayan <mailingradian@gmail.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230523152550.438363-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
flamingradian authored and gregkh committed Jun 9, 2023
1 parent 93f2aa0 commit 2e787e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/misc/fastrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
struct fastrpc_user *user;
unsigned long flags;

/* No invocations past this point */
spin_lock_irqsave(&cctx->lock, flags);
cctx->rpdev = NULL;
list_for_each_entry(user, &cctx->users, user)
fastrpc_notify_users(user);
spin_unlock_irqrestore(&cctx->lock, flags);
Expand All @@ -2175,7 +2177,6 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)

of_platform_depopulate(&rpdev->dev);

cctx->rpdev = NULL;
fastrpc_channel_ctx_put(cctx);
}

Expand Down

0 comments on commit 2e787e5

Please sign in to comment.