DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: dev@dpdk.org, thomas@monjalon.net,
	 Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
Subject: Re: [PATCH v2] eal: fix thread race in control thread creation
Date: Thu, 9 Mar 2023 10:01:07 +0100	[thread overview]
Message-ID: <CAJFAV8zVPdppkqSCeKjitEg-fiFcBrap7t0jOor856Fx0pHSqg@mail.gmail.com> (raw)
In-Reply-To: <1677704982-2643-1-git-send-email-roretzla@linux.microsoft.com>

On Wed, Mar 1, 2023 at 10:09 PM Tyler Retzlaff
<roretzla@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
> 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
> 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
> 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@linux.microsoft.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Honnappa reached out offlist and proposed to send the discussed rework
as a followup patch.
So I'll take this fix as is for now.

Applied, thanks Tyler.


-- 
David Marchand


  parent reply	other threads:[~2023-03-09  9:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 17:17 [PATCH] " Tyler Retzlaff
2023-03-01  8:19 ` David Marchand
2023-03-01 21:09 ` [PATCH v2] " Tyler Retzlaff
2023-03-02  1:30   ` Honnappa Nagarahalli
2023-03-02  1:45     ` Tyler Retzlaff
2023-03-02  4:08       ` Honnappa Nagarahalli
2023-03-07 13:53         ` David Marchand
2023-03-07 17:54           ` Tyler Retzlaff
2023-03-09  9:01   ` David Marchand [this message]
2023-03-01 21:07 Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJFAV8zVPdppkqSCeKjitEg-fiFcBrap7t0jOor856Fx0pHSqg@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=roretzla@linux.microsoft.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).