Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2799298imu; Fri, 23 Nov 2018 15:06:13 -0800 (PST) X-Google-Smtp-Source: AJdET5dfEAMVrxBvawWIa1usXrDFm86X1BHtwrbd3Lhs4MLRsZmIYHyqiMSb4NLmk0asLo7KuP19 X-Received: by 2002:aa7:8497:: with SMTP id u23mr17852075pfn.220.1543014373045; Fri, 23 Nov 2018 15:06:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543014373; cv=none; d=google.com; s=arc-20160816; b=J7EtRFlzQ0uY6RsZF1NrSKsRnToP9yni/MXpAZWufPsmBeuB5EDieUHJwlpzgAgP+Q zmIY2TrhGUsWuzk8mWG8FgYRdCCUl8JxZI88RjApHdSjL+dx/F4pe8TFSJbaW01CVRKK jWWv6I7qyNw+3t9lMJKxMBeNZ3PYeQCxsabVFU7IkPCf6oJpEX/Yy3hBYtFQwJoDPI/g WsJ2vo27+q/VPE81C09rBASHM5T95SSbbRckOaicbyrHuO3UQpCYsSBL/Sf1+gjbXVH/ 3OrSMcIvvERa9uq7D+ACnLUjKmatXdEyymljhB8/I8BbSjkAcZsIRpv9xKUAZ3B8sn9F b/Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=7NRDx1IP/cReEfgNC17ZJfTMwYc0loFL6uFzyLgkcw0=; b=V87n2KhTWPq+nnDmFa7WurwpJwqXN+zMpmpEIe88fcdDyT6lYLmOWK2HPhrVKCeFjE 0wrOENxyi3hfCIdPm9MaQJWtdlS/MXvBTA+vVDmusP0OaRC+d9fvzdWiPCRWCdjWk0w/ DGNbTcAIUZh9MRcSoc2PPr9Atp3Kr/cdr5IJ0mpYiUkKzZ+IbIzGxYVjcS/ghYRjCpZj uHQb6CIJlS3be3toE0rUj6i47ZkSI9f2lBFJoblq7OsSfwHIWZHB0aRbv+VqgZllp5VZ vnTGj3gdM4qbDDgsSDw6ipqN3soXVMqMbvX2HoLMMM61MGbyPf+K7qcluo+IabAbWzX+ RTAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z129si12482821pfz.13.2018.11.23.15.05.57; Fri, 23 Nov 2018 15:06:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437631AbeKWCBE (ORCPT + 99 others); Thu, 22 Nov 2018 21:01:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42594 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730517AbeKWCBE (ORCPT ); Thu, 22 Nov 2018 21:01:04 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D093E31256BE; Thu, 22 Nov 2018 15:21:15 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-116-170.ams2.redhat.com [10.36.116.170]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 507F85C21E; Thu, 22 Nov 2018 15:21:10 +0000 (UTC) From: Florian Weimer To: Rich Felker Cc: Mathieu Desnoyers , carlos , Joseph Myers , Szabolcs Nagy , libc-alpha , Thomas Gleixner , Ben Maurer , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Will Deacon , Dave Watson , Paul Turner , linux-kernel , linux-api Subject: Re: [RFC PATCH v4 1/5] glibc: Perform rseq(2) registration at nptl init and thread creation References: <20181121183936.8176-1-mathieu.desnoyers@efficios.com> <20181122143603.GD23599@brightrain.aerifal.cx> <782067422.9852.1542899056778.JavaMail.zimbra@efficios.com> <87a7m1ywni.fsf@oldenburg.str.redhat.com> <20181122151710.GF23599@brightrain.aerifal.cx> Date: Thu, 22 Nov 2018 16:21:02 +0100 In-Reply-To: <20181122151710.GF23599@brightrain.aerifal.cx> (Rich Felker's message of "Thu, 22 Nov 2018 10:17:10 -0500") Message-ID: <875zwpyw81.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 22 Nov 2018 15:21:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Rich Felker: > On Thu, Nov 22, 2018 at 04:11:45PM +0100, Florian Weimer wrote: >> * Mathieu Desnoyers: >> >> > Thoughts ? >> > >> > /* Unregister rseq TLS from kernel. */ >> > if (has_rseq && __rseq_unregister_current_thread ()) >> > abort(); >> > >> > advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd, >> > pd->guardsize); >> > >> > /* If the thread is detached free the TCB. */ >> > if (IS_DETACHED (pd)) >> > /* Free the TCB. */ >> > __free_tcb (pd); >> >> Considering that we proceed to free the TCB, I really hope that all >> signals are blocked at this point. (I have not checked this, though.) >> >> Wouldn't this address your concern about access to the rseq area? > > I'm not familiar with glibc's logic here, but for other reasons, I > don't think freeing it is safe until the kernel task exit futex (set > via clone or set_tid_address) has fired. I would guess __free_tcb just > sets up for it to be reclaimable when this happens rather than > immediately freeing it for reuse. Right, but in case of user-supplied stacks, we actually free TLS memory at this point, so signals need to be blocked because the TCB is (partially) gone after that. Thanks, Florian