From patchwork Thu Jul 20 10:39:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1810388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=rIr3RJHB; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R68Mq72Gvz1yXp for ; Thu, 20 Jul 2023 20:40:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B0733856969 for ; Thu, 20 Jul 2023 10:40:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B0733856969 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689849605; bh=dzWWyFbqiw4u6bzC1setzoDFGgMQpT2hTjAim5c9QE4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=rIr3RJHB0i1GRn0K6xlRQsQU/8SGH4FtvShtQkA9w99G34dbi6kOHG7PkcZFTQb9/ Tj50CBCfD0hh/zu0hbNbpWGaUkCM2vlJ2Sdby1jb27mQKKOe+SI5B0x5ETS7tUSUur 5RRcHm+b25gfogEEDyTjFYkxTSiYagmiRjezb8WY= 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 509353858CDB for ; Thu, 20 Jul 2023 10:39:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 509353858CDB Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-256-4K2ga3ebMQqjcwMT_9r_Dw-1; Thu, 20 Jul 2023 06:39:48 -0400 X-MC-Unique: 4K2ga3ebMQqjcwMT_9r_Dw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CCE693C100B4; Thu, 20 Jul 2023 10:39:47 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2306B1121315; Thu, 20 Jul 2023 10:39:46 +0000 (UTC) To: libc-alpha@sourceware.org Cc: Mathieu Desnoyers Subject: [PATCH] nptl: Unconditionally use a 32-byte rseq area Date: Thu, 20 Jul 2023 12:39:45 +0200 Message-ID: <87tttyooi6.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.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 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+incoming=patchwork.ozlabs.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. --- nptl/descr.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) base-commit: 3edc4ff2ceff4a59587ebecb94148d3bcfa1df62 diff --git a/nptl/descr.h b/nptl/descr.h index d06abd6ad9..abc9282ef7 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -405,8 +405,19 @@ 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. */