From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C2FAA41E38; Thu, 9 Mar 2023 10:01:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A647340ED7; Thu, 9 Mar 2023 10:01:22 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id F0081400D7 for ; Thu, 9 Mar 2023 10:01:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678352481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UYsxI7ydvTe4bNYsghVuRqNDaoO9C6MUX2NDAxrVqII=; b=bHXovOlNB/sHSrkFPBna968eSlE+hD6ecXA01/9pvXAa3ZKCfF0G1m7jvj851pO1ay3NZg 3hKPXEvkg0tcTEaablwsyZVf19sJ1CozT5BxGZbPLS1zW/eJ1wSUpgUlbWzV5tfzni9CKd sqZOMLGImtydnDmaGIuZbThQjS7tVDQ= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-438-SOWXl3YLMdubGI1_FdFcoQ-1; Thu, 09 Mar 2023 04:01:20 -0500 X-MC-Unique: SOWXl3YLMdubGI1_FdFcoQ-1 Received: by mail-pf1-f198.google.com with SMTP id w3-20020aa78583000000b005d244af158eso884922pfn.23 for ; Thu, 09 Mar 2023 01:01:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678352479; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UYsxI7ydvTe4bNYsghVuRqNDaoO9C6MUX2NDAxrVqII=; b=v0gB/ggGdWZQGM/oC2DOHNv8qevkfOLE0fHOiLw6WCJ8zDVr93wCNg8/DmVDo+W9tX klb57JC1mac5CHlRJ9eQb5bWHPdWGh79SS+AgqsITIHBg4X3ZLjALznjll8Trgo9HPfB KFEwiuoULnPs0yZnPkVx5V9M2NJ6CeU8mADcAgkAJv00D7JBXYIiVjmnfOHtrCtDwkFy v1DRiEFubsXccs5LNK6DEbo9iSBUIG5aIiuVY0FRUsR+nw4uIAnQie7zcN62Iuxu1ybP ldRX8xFBkjr22tVrkpcTQd/QaiY3vUXwVyxGgqTxwk5yeicddzRpwHkYqFzp8/vvYpzC FZ6g== X-Gm-Message-State: AO0yUKVxx9lF9DK+5WPP+h8dpA3V89znZUSAl6WRNN9K9VQwdUPIAETF MTsCfCZSOpsvoR9PWR1M0zXgbYww4MPCECK8m7TyRNhlaQGythue0MGSga73iRd2Vm2YKpQtX9t oPxNhZInMWp3VuYf6Qhk= X-Received: by 2002:a17:902:efce:b0:19b:5233:51d8 with SMTP id ja14-20020a170902efce00b0019b523351d8mr8470609plb.13.1678352479349; Thu, 09 Mar 2023 01:01:19 -0800 (PST) X-Google-Smtp-Source: AK7set+gjA+Pz+TIjvTtTcFHC/hBoJk6Wf8gUZsXVaJq1QaTB9VB3xpJ5FH44KNWl4cKxUhQpXkvtukB+lBPAp3dmtw= X-Received: by 2002:a17:902:efce:b0:19b:5233:51d8 with SMTP id ja14-20020a170902efce00b0019b523351d8mr8470597plb.13.1678352479023; Thu, 09 Mar 2023 01:01:19 -0800 (PST) MIME-Version: 1.0 References: <1677518230-1194-1-git-send-email-roretzla@linux.microsoft.com> <1677704982-2643-1-git-send-email-roretzla@linux.microsoft.com> In-Reply-To: <1677704982-2643-1-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Thu, 9 Mar 2023 10:01:07 +0100 Message-ID: Subject: Re: [PATCH v2] eal: fix thread race in control thread creation To: Tyler Retzlaff Cc: dev@dpdk.org, thomas@monjalon.net, Honnappa Nagarahalli X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Mar 1, 2023 at 10:09=E2=80=AFPM Tyler Retzlaff 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 > Reviewed-by: David Marchand 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. --=20 David Marchand