From patchwork Sat Jun 27 00:54:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1318189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 ozlabs.org (Postfix) with ESMTPS id 49twJm1zzyz9sRk for ; Sat, 27 Jun 2020 10:55:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2250A3870854; Sat, 27 Jun 2020 00:55:00 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id D79653851C1B for ; Sat, 27 Jun 2020 00:54:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D79653851C1B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id A1AB712AB; Sat, 27 Jun 2020 02:54:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0HRDfXOX7cSQ; Sat, 27 Jun 2020 02:54:55 +0200 (CEST) Received: from function (unknown [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id AAD7912A5; Sat, 27 Jun 2020 02:54:55 +0200 (CEST) Received: from samy by function with local (Exim 4.94) (envelope-from ) id 1joz7O-00GRhc-0U; Sat, 27 Jun 2020 02:54:54 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd, commited] htl: avoid cancelling threads inside critical sections Date: Sat, 27 Jun 2020 02:54:53 +0200 Message-Id: <20200627005453.3919695-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Like hurd_thread_cancel does. * sysdeps/mach/hurd/htl/pt-docancel.c: Include (__pthread_do_cancel): Lock target thread's critical_section_lock and ss lock around thread mangling. --- sysdeps/mach/hurd/htl/pt-docancel.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sysdeps/mach/hurd/htl/pt-docancel.c b/sysdeps/mach/hurd/htl/pt-docancel.c index 93961060a2..52010b6edf 100644 --- a/sysdeps/mach/hurd/htl/pt-docancel.c +++ b/sysdeps/mach/hurd/htl/pt-docancel.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include @@ -47,10 +48,16 @@ __pthread_do_cancel (struct __pthread *p) else { error_t err; + struct hurd_sigstate *ss = _hurd_thread_sigstate (p->kernel_thread); + + __spin_lock (&ss->critical_section_lock); + __spin_lock (&ss->lock); err = __thread_suspend (p->kernel_thread); assert_perror (err); + __spin_unlock (&ss->lock); + err = __thread_abort (p->kernel_thread); assert_perror (err); @@ -60,6 +67,8 @@ __pthread_do_cancel (struct __pthread *p) err = __thread_resume (p->kernel_thread); assert_perror (err); + + _hurd_critical_section_unlock (ss); } return 0;