Skip to content

Commit c0ffb99

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

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gum/gum.c

+17
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,20 @@ 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+
{
761+
cpu_supports_cet_ss = FALSE;
762+
}
763+
#endif
764+
748765
if (cpu_supports_cet_ss)
749766
features |= GUM_CPU_CET_SS;
750767

0 commit comments

Comments
 (0)