Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1532519ybt; Thu, 2 Jul 2020 07:47:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf+lUcgcgqX7k034G3aJBW8p/LObCPy4G4Yp9NiJFdd/5m7fbiX0s2DoAc4HIZod3x/hlw X-Received: by 2002:a17:906:780f:: with SMTP id u15mr15919499ejm.295.1593701258386; Thu, 02 Jul 2020 07:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593701258; cv=none; d=google.com; s=arc-20160816; b=mS+x8XadMSJ6U4FQwLVR8B9rdrRPs29BGSBo1doSOeI8V389PIC1ySQNSlR7G3Jl3f ERk+6W+M48yKVyhpmqnnMGkS5hAXJKKrVb4mSBfc+aMN1QU9I45jGRfSCR6d9fbvjq4k dArAYoZ5sITpEqJnAWUfoP37VLOj4VRF/gx0o6W9AxdivrA/W6kw9emCyjdN5oGD3mzS 8qhel3aBTfU+IXBEe2/6fzASrw59KSfC7/k/omULte1UPrSloMUWjPeRHZJv6Sju4Dxe T7LWuAIq4l4rHyPpYCbyWraVFx4GgDy0JoUEQdWI4REYxR3H6EHgCeZXjnGLYzxS3ktg v7rg== 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:dkim-signature; bh=sfReHjMG1okIi6bUbbQpOqD3Ch8gtx1iU9O9hVtsN/8=; b=VASS81prEsRfaGGpkcVWmPnP6rzRwbjyWF3dawzTG11ztv9aO3KjaC4o6h27TEyCn7 gwY+g02wxhubhfbM75Z4RfWj7ELU5+1Q3LjWTVfzGtz9RUj2IKUjDahz7CMmyQZoBPOi LYlq4rVdoO/uKMgUN7kasYWT5yI6r3GKQTmZ1i6PzgHtoxmTRFiOb4bb246h1OPv988K ngdnUuHnhYl4F2woxX0rTuRG5gXgPSJidHy0oPZq2YeKTN31bEh+oejmzs1S+LMWcONv RDqriw6Ru+PxjpGr0XSaYMW/A3hrbGH/0Z6Fhrs6Pz4mpdNbRegGwQi0/2ojHrGWJX3m 2Upg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=emc+bdZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm12si5747274edb.333.2020.07.02.07.47.15; Thu, 02 Jul 2020 07:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=emc+bdZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729974AbgGBOqp (ORCPT + 99 others); Thu, 2 Jul 2020 10:46:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:31585 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729940AbgGBOqk (ORCPT ); Thu, 2 Jul 2020 10:46:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593701198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sfReHjMG1okIi6bUbbQpOqD3Ch8gtx1iU9O9hVtsN/8=; b=emc+bdZ4qTXh9qfjakR7wbzVYuHXSwygSqm2Lrv+4aywCVnZCuYlHXq9d1w6D80k1lcGnP bXkTp6BNpPGkO0DMMB46C7slWX0BkTTdRBKOOjLAK9JRrwVDnkqPSafPkoWqsJKxXjXPNT 49SXu079n17mEPzr5PjHtzhd/aT2+ps= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-467-GbGUuS2aPx2QW6v9bWRqWQ-1; Thu, 02 Jul 2020 10:46:32 -0400 X-MC-Unique: GbGUuS2aPx2QW6v9bWRqWQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C383A879512; Thu, 2 Jul 2020 14:46:24 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-162.ams2.redhat.com [10.36.112.162]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8557B1CA; Thu, 2 Jul 2020 14:46:18 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers via Libc-alpha Cc: Mathieu Desnoyers , Rich Felker , linux-api@vger.kernel.org, Boqun Feng , Will Deacon , linux-kernel@vger.kernel.org, Peter Zijlstra , Ben Maurer , Dave Watson , Thomas Gleixner , "Paul E. McKenney" , Paul Turner , Joseph Myers , Carlos O'Donell Subject: Re: [PATCH 1/3] glibc: Perform rseq registration at C startup and thread creation (v22) References: <20200629190036.26982-1-mathieu.desnoyers@efficios.com> <20200629190036.26982-2-mathieu.desnoyers@efficios.com> Date: Thu, 02 Jul 2020 16:46:17 +0200 In-Reply-To: <20200629190036.26982-2-mathieu.desnoyers@efficios.com> (Mathieu Desnoyers via Libc-alpha's message of "Mon, 29 Jun 2020 15:00:34 -0400") Message-ID: <87o8oy9dqe.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mathieu Desnoyers via Libc-alpha: > Register rseq TLS for each thread (including main), and unregister for > each thread (excluding main). "rseq" stands for Restartable Sequences. > > See the rseq(2) man page proposed here: > https://lkml.org/lkml/2018/9/19/647 > > Those are based on glibc master branch commit 3ee1e0ec5c. > The rseq system call was merged into Linux 4.18. > > The TLS_STATIC_SURPLUS define is increased to leave additional room for > dlopen'd initial-exec TLS, which keeps elf/tst-auditmany working. > > The increase (76 bytes) is larger than 32 bytes because it has not been > increased in quite a while. The cost in terms of additional TLS storage > is quite significant, but it will also obscure some initial-exec-related > dlopen failures. We need another change to get this working on most non-x86 architectures: diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 817bcbbf59..ca13778ca9 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -134,6 +134,12 @@ void _dl_determine_tlsoffset (void) { size_t max_align = TLS_TCB_ALIGN; + /* libc.so with rseq has TLS with 32-byte alignment. Since TLS is + initialized before audit modules are loaded and slotinfo + information is available, this is not taken into account below in + the audit case. */ + max_align = MAX (max_align, 32U); + size_t freetop = 0; size_t freebottom = 0; This isn't visible on x86-64 because TLS_TCB_ALIGN is already 64 there. I plan to re-test with this fix and push the series. Carlos, is it okay if I fold in the dl-tls.c change if testing looks good? Thanks, Florian