[PATCH] eal: fix thread race in control thread creation
David Marchand
david.marchand at redhat.com
Wed Mar 1 09:19:21 CET 2023
On Mon, Feb 27, 2023 at 6:17 PM Tyler Retzlaff
<roretzla at linux.microsoft.com> wrote:
>
> When ctrl_thread_init transitions params->ctrl_thread_status from
> CTRL_THREAD_LAUNCHING the creating thread and new thread may run
> concurrently leading to unsynchronized access to params.
>
> This permits races for both the failure and success paths after
> ctrl_thread_status is stored.
> * params->ret may be loaded in ctrl_thread_init failure path
> * params->arg may be loaded in ctrl_thread_start or
> control_thread_start when calling start_routine.
>
> for ctrl_thread_init remove the params->ret load and just return 1 since
For*
> it is only interpreted as a indicator of success / failure of
> ctrl_thread_init.
>
> for {ctrl,control}_thread_start store param->arg in stack allocated
For*
> storage prior to calling ctrl_thread_init and use the copy when calling
> start_routine.
>
> for control_thread_start if ctrl_thread_init fails just return 0 instead
For*
> of loading params->ret, since the value returned is unused when
> ctrl_thread_status is set to CTRL_THREAD_ERROR when ctrl_thread_init
> fails.
>
> Fixes: 878b7468eacb ("eal: add platform agnostic control thread API")
>
> Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
Reviewed-by: David Marchand <david.marchand at redhat.com>
Thanks Tyler.
--
David Marchand
More information about the dev
mailing list