diff --git a/kernel/vhost_task.c b/kernel/vhost_task.c index 01bf7b0e2c5b..6cb3b8b26768 100644 --- a/kernel/vhost_task.c +++ b/kernel/vhost_task.c @@ -58,9 +58,15 @@ static int vhost_task_fn(void *data) * new work and flushed. */ if (!test_bit(VHOST_TASK_FLAGS_STOP, &vtsk->flags)) { - set_bit(VHOST_TASK_FLAGS_KILLED, &vtsk->flags); if (vtsk->handle_sigkill) vtsk->handle_sigkill(vtsk->data); + + /* + * Mark the task KILLED *after* giving the owner the chance to + * handle SIGKILL to avoid false positives on the sanity check + * in __vhost_task_wake(). + */ + set_bit(VHOST_TASK_FLAGS_KILLED, &vtsk->flags); } mutex_unlock(&vtsk->exit_mutex); complete(&vtsk->exited);