1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

x86: Move CET control to _dl_x86_feature_control [BZ #25887]

1. Include <dl-procruntime.c> to get architecture specific initializer in
rtld_global.
2. Change _dl_x86_feature_1[2] to _dl_x86_feature_1.
3. Add _dl_x86_feature_control after _dl_x86_feature_1, which is a
struct of 2 bitfields for IBT and SHSTK control

This fixes [BZ #25887].
This commit is contained in:
H.J. Lu
2020-04-28 10:05:25 -07:00
parent cbfc16122e
commit 674ea88294
9 changed files with 81 additions and 68 deletions

View File

@ -336,28 +336,18 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
}
# if CET_ENABLED
# include <cet-tunables.h>
attribute_hidden
void
TUNABLE_CALLBACK (set_x86_ibt) (tunable_val_t *valp)
{
if (DEFAULT_MEMCMP (valp->strval, "on", sizeof ("on")) == 0)
{
GL(dl_x86_feature_1)[1] &= ~((1 << CET_MAX) - 1);
GL(dl_x86_feature_1)[1] |= CET_ALWAYS_ON;
}
GL(dl_x86_feature_control).ibt = cet_always_on;
else if (DEFAULT_MEMCMP (valp->strval, "off", sizeof ("off")) == 0)
{
GL(dl_x86_feature_1)[1] &= ~((1 << CET_MAX) - 1);
GL(dl_x86_feature_1)[1] |= CET_ALWAYS_OFF;
}
GL(dl_x86_feature_control).ibt = cet_always_off;
else if (DEFAULT_MEMCMP (valp->strval, "permissive",
sizeof ("permissive")) == 0)
{
GL(dl_x86_feature_1)[1] &= ~((1 << CET_MAX) - 1);
GL(dl_x86_feature_1)[1] |= CET_PERMISSIVE;
}
GL(dl_x86_feature_control).ibt = cet_permissive;
}
attribute_hidden
@ -365,21 +355,12 @@ void
TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *valp)
{
if (DEFAULT_MEMCMP (valp->strval, "on", sizeof ("on")) == 0)
{
GL(dl_x86_feature_1)[1] &= ~(((1 << CET_MAX) - 1) << CET_MAX);
GL(dl_x86_feature_1)[1] |= (CET_ALWAYS_ON << CET_MAX);
}
GL(dl_x86_feature_control).shstk = cet_always_on;
else if (DEFAULT_MEMCMP (valp->strval, "off", sizeof ("off")) == 0)
{
GL(dl_x86_feature_1)[1] &= ~(((1 << CET_MAX) - 1) << CET_MAX);
GL(dl_x86_feature_1)[1] |= (CET_ALWAYS_OFF << CET_MAX);
}
GL(dl_x86_feature_control).shstk = cet_always_off;
else if (DEFAULT_MEMCMP (valp->strval, "permissive",
sizeof ("permissive")) == 0)
{
GL(dl_x86_feature_1)[1] &= ~(((1 << CET_MAX) - 1) << CET_MAX);
GL(dl_x86_feature_1)[1] |= (CET_PERMISSIVE << CET_MAX);
}
GL(dl_x86_feature_control).shstk = cet_permissive;
}
# endif
#endif