[PATCH] x86_64: Check SHSTK status agreement in tst-cet-legacy-1
Hyungwon Kim
hwkim568@gmail.com
Tue Nov 17 01:11:38 GMT 2026
The existing test only checked legacy DSO linking behavior, without
verifying that the SHSTK state reported by CPU_FEATURE_ACTIVE matches
the actual shadow stack pointer value returned by _get_ssp.
Add a check that these two values agree. If they disagree, the test
now fails immediately instead of silently skipping the mismatch.
Tested on x86_64.
Signed-off-by: Hyungwon Kim <hwkim568@gmail.com>
---
sysdeps/x86_64/tst-cet-legacy-1.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/sysdeps/x86_64/tst-cet-legacy-1.c b/sysdeps/x86_64/tst-cet-legacy-1.c
index 45e6d6a09b..ca82c732d5 100644
--- a/sysdeps/x86_64/tst-cet-legacy-1.c
+++ b/sysdeps/x86_64/tst-cet-legacy-1.c
@@ -17,6 +17,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <x86intrin.h>
+#include <sys/platform/x86.h>
+#include <support/test-driver.h>
+#include <support/xunistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -26,6 +30,16 @@ extern int in_dso_2 (void);
static int
do_test (void)
{
+ if (_get_ssp () != 0)
+ {
+ if (!CPU_FEATURE_ACTIVE (SHSTK))
+ return EXIT_FAILURE;
+ }
+ else
+ {
+ if (CPU_FEATURE_ACTIVE (SHSTK))
+ return EXIT_FAILURE;
+ }
if (in_dso_1 () != 0x1234678)
{
puts ("in_dso_1 () != 0x1234678");
@@ -38,7 +52,7 @@ do_test (void)
exit (1);
}
- return 0;
+ return EXIT_SUCCESS;
}
#include <support/test-driver.c>
--
2.43.0
More information about the Libc-alpha
mailing list