x86_64: Always initialize ssp_base in the TCB if SHSTK is enabled

This commit is contained in:
Florian Weimer 2024-05-30 15:43:07 +02:00
parent f5bfd0e47c
commit 90ee0d8730
2 changed files with 37 additions and 0 deletions

View File

@ -333,6 +333,14 @@ _dl_cet_setup_features (unsigned int cet_feature)
enabled from executable, not necessarily supported by kernel. */
if (cet_feature != 0)
{
void **ssp;
asm ("rdsspq %0"
: "=r" (ssp)
: "0" (0));
if (ssp != NULL)
/* The caller is the top-most frame, hence the + 8. */
THREAD_SETMEM (THREAD_SELF, header.ssp_base, ssp + 8);
cet_feature = dl_cet_get_cet_status ();
if (cet_feature != 0)
{

View File

@ -0,0 +1,29 @@
/* Architecture-specific thread initialization for NPTL. x86-64 version.
Copyright (C) 2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
static inline __always_inline void
__nptl_arch_thread_init (void)
{
#if CET_ENABLED
void **ssp;
asm ("rdsspq %0"
: "=r" (ssp)
: "0" (0));
THREAD_SETMEM (THREAD_SELF, header.ssp_base, ssp);
#endif
}