From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.5 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id EE3631F8C6 for ; Mon, 23 Aug 2021 20:01:58 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 347BC3858010 for ; Mon, 23 Aug 2021 20:01:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 347BC3858010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629748918; 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=i2A0sRdX8XM+CEWqya/jv8LJszaunk/RUQSBtBaCkZjtLRnV7//pgE0scuY17q0og dv+Kg4hZxKyw4iotAN/yGDX6CCDpeQ+jyjAHkxXtfVPmdCfIXwjOaxNVIZhGabptGh t1ncaKhywQwRoETjyCKaLioW30J4pspnFoLBMxI4= 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 Content-Transfer-Encoding: 8bit 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: , From: Adhemerval Zanella via Libc-alpha Reply-To: Adhemerval Zanella Cc: Florian Weimer Errors-To: libc-alpha-bounces+e=80x24.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) -- 2.30.2