From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 023F7385DC02; Fri, 21 Jul 2023 14:20:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 023F7385DC02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689949214; bh=Kd915MwExKmWvyMwfd3pZRt+B/HxHMzRXgIp491QkR8=; h=From:To:Subject:Date:From; b=tzbONI5vI1Nq6m1yWZxFUaCzZlmyidW8gFU4fdRDKDiLUEr2yyQ5iQnm13FWvFr5M INwwHCNWe0pzD7tFg7GzpnihEc4LxDRFpNVaVKdcAB7BvwVmb1czTbZRIedKO7Qa14 I5zngmbC6G3UOWW/RdJgh7Fduwyc5F8vNyLIJQ+0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc] nptl: Unconditionally use a 32-byte rseq area X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/master X-Git-Oldrev: f7f181c12c140ff1fe45376b98fe32eb491e363f X-Git-Newrev: 2c6b4b272e6b4d07303af25709051c3e96288f2d Message-Id: <20230721142014.023F7385DC02@sourceware.org> Date: Fri, 21 Jul 2023 14:20:13 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2c6b4b272e6b4d07303af25709051c3e96288f2d commit 2c6b4b272e6b4d07303af25709051c3e96288f2d Author: Florian Weimer Date: Fri Jul 21 16:18:18 2023 +0200 nptl: Unconditionally use a 32-byte rseq area 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. Diff: --- nptl/descr.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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