From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 0BEB03852C53; Wed, 23 Nov 2022 14:46:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BEB03852C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669214784; bh=QVdWI2se4+j0QMKPfE406Rb1AN5FtYzfTymn6iaMx7w=; h=From:To:Subject:Date:From; b=erC76Tjbr8BhK/wfbKXUuw//C7EGMej3HxUbgMzuR3XLV3qYJhuZHRWAUAS5fjZX3 BdeR2UjK4F9fcdOVhLPwSH48AZZFUsNilUIEg/RJK8/Tz3wtJLnyNpOneHRffhPUg9 D4zaHkb6q5IwEwLaYCuU5IF19qzoRQh/qqdTmg78= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] cheri: rseq: remove const to avoid readonly permission X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 8f6565fa273e95dfedf84366629e815f759d3f76 X-Git-Newrev: 1b8d019265ebe0b6c27a8e845de3127449956dd6 Message-Id: <20221123144624.0BEB03852C53@sourceware.org> Date: Wed, 23 Nov 2022 14:46:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1b8d019265ebe0b6c27a8e845de3127449956dd6 commit 1b8d019265ebe0b6c27a8e845de3127449956dd6 Author: Szabolcs Nagy Date: Tue Mar 1 09:44:14 2022 +0000 cheri: rseq: remove const to avoid readonly permission Using const on the definition does not work for a pure capability ABI: the capability permissions when accessing the object will be read only. Use a hack to hide the public declaration in the TU where the const objects are initialized. (This should work on non-capability targets too, but to err on the safe side only enable the hack on capability targets.) Diff: --- sysdeps/nptl/dl-tls_init_tp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c index 53fba774a5..e4d7bb71ad 100644 --- a/sysdeps/nptl/dl-tls_init_tp.c +++ b/sysdeps/nptl/dl-tls_init_tp.c @@ -16,6 +16,15 @@ License along with the GNU C Library; if not, see . */ +#ifdef __CHERI_PURE_CAPABILITY__ +/* This hack ensures that the later indirectly included public const + declaration does not conflict with the non-const definition here. */ +# define __rseq_size __rseq_size_public_const +# define __rseq_offset __rseq_offset_public_const +# include +# undef __rseq_size +# undef __rseq_offset +#endif #include #include #include @@ -45,8 +54,13 @@ rtld_mutex_dummy (pthread_mutex_t *lock) #endif const unsigned int __rseq_flags; +#ifdef __CHERI_PURE_CAPABILITY__ +unsigned int __rseq_size attribute_relro; +ptrdiff_t __rseq_offset attribute_relro; +#else const unsigned int __rseq_size attribute_relro; const ptrdiff_t __rseq_offset attribute_relro; +#endif void __tls_pre_init_tp (void)