From patchwork Thu Jul 20 11:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 72992 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 D3679385DC05 for ; Thu, 20 Jul 2023 11:46:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3679385DC05 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689853608; bh=hmukLyAglw6jqy/i4cj/zBJXve126B/s3vEa3EvI7jw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=uX/sjyo00rvzNVh5YIZIutduS0gDC8luCktqAdILOZxMY/zuEk5N1bDMML13exhKw KL1zB/xab1BQ6r+Mb+Q2adzaFQtALwIRSG9/T9tLO7LRi2hRI/ExjGDBR5VvdWTQFO u5vmFBA/3/JOkrvE8j4y/NgtHhY5jXKpj8xmpoaM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7F5D83853D21 for ; Thu, 20 Jul 2023 11:46:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F5D83853D21 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-tg0qfDtuODWLuKvewbebgQ-1; Thu, 20 Jul 2023 07:46:16 -0400 X-MC-Unique: tg0qfDtuODWLuKvewbebgQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7244186F122; Thu, 20 Jul 2023 11:46:16 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0963492C13; Thu, 20 Jul 2023 11:46:15 +0000 (UTC) To: libc-alpha@sourceware.org Cc: Mathieu Desnoyers Subject: [PATCH v2] nptl: Unconditionally use a 32-byte rseq area Date: Thu, 20 Jul 2023 13:46:14 +0200 Message-ID: <87lefaolfd.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" If the kernel headers provide a larger struct rseq, we used that size as the argument to the rseq system call. As a result, rseq registration would fail on older kernels which only accept size 32. Tested on x86_64-linux-gnu. Built with build-many-glibcs.py. This needs to be backported all the way to glibc 2.35. --- v2: Drop further struct rseq reference on ia64. Remove #include . nptl/descr.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) base-commit: 3edc4ff2ceff4a59587ebecb94148d3bcfa1df62 diff --git a/nptl/descr.h b/nptl/descr.h index d06abd6ad9..0171576c23 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #ifndef TCB_ALIGNMENT @@ -405,14 +404,25 @@ struct pthread /* Used on strsignal. */ struct tls_internal_t tls_state; - /* rseq area registered with the kernel. */ - struct rseq rseq_area; + /* rseq area registered with the kernel. Use a custom definition + here to isolate from kernel struct rseq changes. The + implementation of sched_getcpu needs acccess to the cpu_id field; + the other fields are unused and not included here. */ + union + { + struct + { + uint32_t cpu_id_start; + uint32_t cpu_id; + }; + char pad[32]; /* Original rseq area size. */ + } rseq_area __attribute__ ((aligned (32))); /* Amount of end padding, if any, in this structure. This definition relies on rseq_area being last. */ #define PTHREAD_STRUCT_END_PADDING \ (sizeof (struct pthread) - offsetof (struct pthread, rseq_area) \ - + sizeof (struct rseq)) + + sizeof ((struct pthread) {}.rseq_area)) } __attribute ((aligned (TCB_ALIGNMENT))); static inline bool