-
Notifications
You must be signed in to change notification settings - Fork 14
/
KeVerifyContextIpForUserCet.c
46 lines (42 loc) · 1.17 KB
/
KeVerifyContextIpForUserCet.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
NTSTATUS
KeVerifyContextIpForUserCet (
_In_ PETHREAD Thread,
_In_ PCONTEXT Context,
_In_ PKCONTINUE_TYPE ContinueType,
_Inout_ PULONG_PTR ShadowStack
)
{
PEPROCESS process;
NTSTATUS status;
//
// No need to do anything if shadow stack is not enabled
//
if (!Thread->Tcb.CetShadowStack)
{
return STATUS_SUCCESS;
}
//
// No need to do anything if UserCetSetContextIpValidation is not
// set in this process or if Rip is not being modified
//
process = Thread->Tcb.ApcState.Process;
if (!(process->MitigationFlags2Values.UserCetSetContextIpValidation) ||
!(BooleanFlagOn(Context->ContextFlags, CONTEXT_CONTROL)))
{
return STATUS_SUCCESS;
}
//
// Verify the new Rip target
//
status = KiVerifyContextIpForUserCet(Thread, Context, ContinueType, ShadowStack);
//
// Audit failure if requested and fake success
//
if ((status == STATUS_SET_CONTEXT_DENIED) &&
(process->MitigationFlags2Values.AuditUserCetSetContextIpValidation))
{
KiLogUserCetSetContextIpValidationAudit(*ContinueType);
status = STATUS_SUCCESS;
}
return status;
}