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 46DDC1F8C6 for ; Mon, 23 Aug 2021 20:02:42 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DE183858404 for ; Mon, 23 Aug 2021 20:02:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DE183858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629748961; bh=+/g3+tG6NT5sPPypRLkGtrkjk6b69pZfFSqKQOWlLbk=; 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=Wk/VhP7uo0aKOZTLA9oRq1N5Reos+iAEEGKJIPCc+6T4WrXnSSW6m9SCMdfh+vnri I+bzd04N6Tv/DYpedIWiMaJeR4efrwYRkHzcSeikr34c3mXw4xcsqofJgekmArusWZ TrCU7GXBSc/n85RLX9tMXt8hupVxdkeLYgpqPXos= Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 80AF9385802D for ; Mon, 23 Aug 2021 19:52:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 80AF9385802D Received: by mail-qk1-x729.google.com with SMTP id y144so20541595qkb.6 for ; Mon, 23 Aug 2021 12:52:22 -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=+/g3+tG6NT5sPPypRLkGtrkjk6b69pZfFSqKQOWlLbk=; b=iwByiArcpWGPVtmqzZu4RvKNA907Yvtf7zBUErJ1aQeG27BYWybKfy0Yf5vinpcwEZ ZLBWInVkkVGQqOWhHG+Bj50gzy14KFTbCK6R8Ty6UaEydSpgkFgHeEy7ADxyQZDE/UeR DgDqQUKjpenPea77tJXKkuIiphYDmy8tSf3N5emkz6bag+eXtKoglkk1N8CIMTCtMX+r l7s2n5LwA3VHsbpuLjfjQvJXFQQi8ARjX7AOBonPApMjCt9rO4YnsChha+ssyEgwSWAa FCRT9BiavzFFfv5I4MQMtt7b5IGjtNehq1CVQmkgndIaQAHRN49FejfmMUOzIh51tPBc mzfA== X-Gm-Message-State: AOAM532lJ7SrM+o20/TFOfXRDbYVe5m42wiF6rJYhJtJKujot8rQiUwi 98O5Ft61y+7vYh36BOVp+fI8ZJeXrErD7g== X-Google-Smtp-Source: ABdhPJwWsL281xrpSFqkSrUXI8T8//WIdPWVal9+WsSskkyxIBLzTq79JTjogUwx9YyOi98NjnxD/Q== X-Received: by 2002:a37:749:: with SMTP id 70mr22028807qkh.461.1629748341976; Mon, 23 Aug 2021 12:52:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 12:52:21 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 18/19] nptl: Use tidlock when accessing TID on pthread_setschedprio Date: Mon, 23 Aug 2021 16:50:46 -0300 Message-Id: <20210823195047.543237-19-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_setschedprio.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/nptl/pthread_setschedprio.c b/nptl/pthread_setschedprio.c index 7bb68d3231..f6efdcad8e 100644 --- a/nptl/pthread_setschedprio.c +++ b/nptl/pthread_setschedprio.c @@ -30,11 +30,18 @@ __pthread_setschedprio (pthread_t threadid, int prio) 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; + } + struct sched_param param; param.sched_priority = prio; @@ -60,6 +67,10 @@ __pthread_setschedprio (pthread_t threadid, int prio) lll_unlock (pd->lock, LLL_PRIVATE); +out: + lll_unlock (pd->tidlock, LLL_PRIVATE); + __libc_signal_restore_set (&oldmask); + return result; } versioned_symbol (libc, __pthread_setschedprio, pthread_setschedprio, -- 2.30.2