Skip to content

Commit f670c75

Browse files
committed
cpu-features: Ignore CET SS unless actively used
1 parent dc11cd1 commit f670c75

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

gum/gum.c

+16
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,9 @@ gum_do_query_cpu_features (void)
732732
gboolean cpu_supports_cet_ss = FALSE;
733733
gboolean os_enabled_xsave = FALSE;
734734
guint a, b, c, d;
735+
#ifdef HAVE_WINDOWS
736+
PROCESS_MITIGATION_USER_SHADOW_STACK_POLICY pol;
737+
#endif
735738

736739
if (gum_get_cpuid (7, &a, &b, &c, &d))
737740
{
@@ -745,6 +748,19 @@ gum_do_query_cpu_features (void)
745748
if (cpu_supports_avx2 && os_enabled_xsave)
746749
features |= GUM_CPU_AVX2;
747750

751+
#ifdef HAVE_WINDOWS
752+
if (cpu_supports_cet_ss &&
753+
GetProcessMitigationPolicy(
754+
GetCurrentProcess(),
755+
ProcessUserShadowStackPolicy,
756+
&pol,
757+
sizeof pol
758+
) &&
759+
!pol.EnableUserShadowStack) {
760+
cpu_supports_cet_ss = FALSE;
761+
}
762+
#endif
763+
748764
if (cpu_supports_cet_ss)
749765
features |= GUM_CPU_CET_SS;
750766

0 commit comments

Comments
 (0)