From patchwork Mon Aug 23 19:50:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 44759 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 461573857405 for ; Mon, 23 Aug 2021 20:02:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 461573857405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629748920; bh=eVtWD/sZOl9MYbgZvABZ6k6QQWydYkSauFnGvjjqAXo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OAVE1ed2fVvg3xUmps971O4bbIvBnBJth/51CQSoagLtoTzDE2HmzecKsmPhHWgFj VQQh/Zjf1bCvrbrMGpad2esVmbXZcqa+4fGfEiPM4fokrZYrw3OcqjHN2wWnmCqb7P Vky+rRwPXsF5MHCNeitFZA26YyCo6tPprjHb5rqc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by sourceware.org (Postfix) with ESMTPS id 302113858C2C for ; Mon, 23 Aug 2021 19:52:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 302113858C2C Received: by mail-qk1-x72c.google.com with SMTP id t190so20545491qke.7 for ; Mon, 23 Aug 2021 12:52:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eVtWD/sZOl9MYbgZvABZ6k6QQWydYkSauFnGvjjqAXo=; b=NWXanxfJLZPWplgm/YgCu2KiIrFrbWweIJtyuHDa6C5asio5EBhcSPiA6oKXCklHju PnYgxvawMCKi5wYhy9gZerG3RBBQgVWusNboTS2JSazUO9fFib/6+IHDbzCvUV2YsJba WlKKWYznMezUbytCWfsJOFstx8WGiK7e5ENZ52v/z/D1twLwN3IswrOYsfhcGt83h+RM v8zoAGD3ML2kop3inMh5B8pBY2bj9Y5zNXWSasRB+sVtqulja2TwyUOPzZnxXmthjMDC fDf0V0zG81BVL2fmDxKw/ISfW/AeJ3w/0TGX4phQyXiuzuoqHESfAHb7tLUjlc+4GkBs Kh/A== X-Gm-Message-State: AOAM531sVFcW6+P10CeBpiTX+5TIAGSQdB9aeLQKdyrizplEx9loZuG/ BZxDcVxojK3v/p1UzbqPIt8NPNaPQZtxWg== X-Google-Smtp-Source: ABdhPJxu5krJoYSmx4zSQeQpmpacaLGSMs9R+juN/gjPzaVZm4yLSCkToCH9nA/iK6bD8ve8LJdyog== X-Received: by 2002:ae9:e649:: with SMTP id x9mr15909734qkl.205.1629748335661; Mon, 23 Aug 2021 12:52:15 -0700 (PDT) Received: from birita.. ([2804:431:c7ca:cd83:c38b:b50d:5d9a:43d4]) by smtp.gmail.com with ESMTPSA id s10sm9210935qko.134.2021.08.23.12.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 12:52:15 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 13/19] nptl: Use tidlock when accessing TID on pthread_getschedparam Date: Mon, 23 Aug 2021 16:50:41 -0300 Message-Id: <20210823195047.543237-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210823195047.543237-1-adhemerval.zanella@linaro.org> References: <20210823195047.543237-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Cc: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Checked on x86_64-linux-gnu. --- nptl/pthread_getschedparam.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nptl/pthread_getschedparam.c b/nptl/pthread_getschedparam.c index 94316cf897..c41d2a8341 100644 --- a/nptl/pthread_getschedparam.c +++ b/nptl/pthread_getschedparam.c @@ -29,12 +29,18 @@ __pthread_getschedparam (pthread_t threadid, int *policy, struct pthread *pd = (struct pthread *) threadid; /* Make sure the descriptor is valid. */ - if (INVALID_TD_P (pd)) - /* Not a valid thread handle. */ - return ESRCH; + sigset_t oldmask; + __libc_signal_block_all (&oldmask); + lll_lock (pd->tidlock, LLL_PRIVATE); int result = 0; + if (pd->tid == 0) + { + result = ESRCH; + goto out; + } + /* See CREATE THREAD NOTES in nptl/pthread_create.c. */ lll_lock (pd->lock, LLL_PRIVATE); @@ -68,6 +74,10 @@ __pthread_getschedparam (pthread_t threadid, int *policy, lll_unlock (pd->lock, LLL_PRIVATE); +out: + lll_unlock (pd->tidlock, LLL_PRIVATE); + __libc_signal_restore_set (&oldmask); + return result; } libc_hidden_def (__pthread_getschedparam)