From patchwork Fri Jul 10 20:26:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 40023 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7CDBA3842400; Fri, 10 Jul 2020 20:26:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CDBA3842400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594412801; bh=9aZEIEw6peT2FHJCzKt+vpXNW6cNDdOdc1Rs/MfAguA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Ghz/fuPeqtNa8C7+NnXscpiQTDeHIgkeJPHiDNQWo1J6CK/ouJQjZbiSf+dw76YK6 6FocHHkIXH2NMnA9yO9MGbT/RRFQC5wdCEEJeA/RWaiTvlXa6lyX0S4sBX1l1dsZdG 5UUpfohoo26968NfyJuVFEiLq5C4perXIRPgvimo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id B62EA3844044 for ; Fri, 10 Jul 2020 20:26:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B62EA3844044 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-449-nzarsF2WPee3rAYyT8QJ5Q-1; Fri, 10 Jul 2020 16:26:35 -0400 X-MC-Unique: nzarsF2WPee3rAYyT8QJ5Q-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 1CB971009441 for ; Fri, 10 Jul 2020 20:26:35 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-118.ams2.redhat.com [10.36.113.118]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9684874F44 for ; Fri, 10 Jul 2020 20:26:34 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Support at least 32-byte alignment in static dlopen Date: Fri, 10 Jul 2020 22:26:33 +0200 Message-ID: <87y2nrw1za.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Otherwise loading a dynamically linked libc with rseq support fails, as result of the __rseq_abi TLS variable, which has an alignment of 32 bytes. Reviewed-by: Carlos O'Donell Tested-by: Vineet Gupta Reviewed-by: Alistair Francis Tested-by: Alistair Francis --- csu/libc-tls.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/csu/libc-tls.c b/csu/libc-tls.c index 06e76bd395..3f1655f264 100644 --- a/csu/libc-tls.c +++ b/csu/libc-tls.c @@ -112,6 +112,12 @@ __libc_setup_tls (void) size_t tcb_offset; const ElfW(Phdr) *phdr; + /* libc.so with rseq has TLS with 32-byte alignment. Static dlopen + requires at least 32-byte alignment as well, otherwise loading + libc.so will always fail. */ + if (max_align < 32) + max_align = 32; + struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; /* Look through the TLS segment if there is any. */