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 4C7DB41D44; Wed, 1 Mar 2023 09:19:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E79DE4114A; Wed, 1 Mar 2023 09:19:36 +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 D44E240689 for ; Wed, 1 Mar 2023 09:19:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677658775; 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: in-reply-to:in-reply-to:references:references; bh=WV+LYiW9k3JfOPeucpE6qzphWdnCpg3k2sgbTrCPeCc=; b=RFfgfYDEe3z1qAMyG3HCBbX024Zgm0EnAw0VP8PX4Y0TPQjkk/2jlm+SYrLJaHKuFWgst1 IPKp5wqd/+nC4hEhwIiWtrO0ldrub9Dcc+4xiubAOBKOnS3S+mTX5QB9PkoiPM6G1YNNsr KNdoq0Tr/jgDkNIKOKJsQqokeZa52Ls= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-640-WBzD7sVkPmu-BdY0Ryu2tg-1; Wed, 01 Mar 2023 03:19:34 -0500 X-MC-Unique: WBzD7sVkPmu-BdY0Ryu2tg-1 Received: by mail-pf1-f199.google.com with SMTP id x137-20020a62868f000000b0060017d68643so2759365pfd.18 for ; Wed, 01 Mar 2023 00:19:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677658773; h=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=WV+LYiW9k3JfOPeucpE6qzphWdnCpg3k2sgbTrCPeCc=; b=OOqWgY9RbDx/8mLJGGydJIJHKxWKO5nwUEGRzbcMTLEz3oPl/Ch0aMy5pHQi3GCyx1 u5op5MLxmKePNftkXGLVEeK9LKDg5PPXcqWp9eE9RNzI25iNTEfYr/9JVcC0TRBZuYuJ jLqr0JzxmgwUj8oA5r4y31x7edR0FVBYJ0aXZg3faVAsLMMnHUrU42hiLlqDF5XTKPGm 6laRr7JMESar9r83ha8UW1vIlWSDGOfNWWRXG2uKNzalLH7/ZdYL75bFSFy65dWJkfYr 5n/yqM6nNmfLbGVO8C4yNQusgd2pWqSzIAWdifpAGg5eS8ClTtE4jNoImkIIycltAn1A ZO3Q== X-Gm-Message-State: AO0yUKX/WyB70geFmXxhGClgmoVu4f+cb6oSw1M1hNFGIvxRrOIs1b/L g62WO8GDpeE49/nKRS0V2xKsAje/ltXxxqIfz7J8l42bC+9HJ+BNBo0uNXj0Z/Hym29jd5gdPfR 7XcI+QS6mMOvvRc39mrc= X-Received: by 2002:a17:90a:fae:b0:237:64dc:5acd with SMTP id 43-20020a17090a0fae00b0023764dc5acdmr2315981pjz.7.1677658773045; Wed, 01 Mar 2023 00:19:33 -0800 (PST) X-Google-Smtp-Source: AK7set8+uWBlw70zdykj3G4DMFk4cUJN9VcKgKMKWwguvMLCx3Ryrw3dwX7n7lxL6nhkzmrAOS37BxqQRnVkbc10Kns= X-Received: by 2002:a17:90a:fae:b0:237:64dc:5acd with SMTP id 43-20020a17090a0fae00b0023764dc5acdmr2315974pjz.7.1677658772787; Wed, 01 Mar 2023 00:19:32 -0800 (PST) MIME-Version: 1.0 References: <1677518230-1194-1-git-send-email-roretzla@linux.microsoft.com> In-Reply-To: <1677518230-1194-1-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Wed, 1 Mar 2023 09:19:21 +0100 Message-ID: Subject: Re: [PATCH] eal: fix thread race in control thread creation To: Tyler Retzlaff Cc: dev@dpdk.org, thomas@monjalon.net X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 Mon, Feb 27, 2023 at 6:17 PM 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 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 Reviewed-by: David Marchand Thanks Tyler. -- David Marchand