Bitdefender Hypervisor Memory Introspection
lixcred.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #include "lixcred.h"
6 #include "alerts.h"
7 #include "crc32.h"
8 #include "guests.h"
9 #include "lixfiles.h"
10 #include "lixmm.h"
11 #include "lixprocess.h"
12 #include "lixstack.h"
13 #include "kernvm.h"
14 
15 
21 typedef struct _INTERNAL_CRED
22 {
23  int usage;
24 
25  unsigned int uid;
26  unsigned int guid;
27  unsigned int suid;
28  unsigned int sgid;
29  unsigned int euid;
30  unsigned int egid;
31  unsigned int fsuid;
32  unsigned int fsgid;
34 
35 
39 static LIST_HEAD gCreds = LIST_HEAD_INIT(gCreds);
40 
44 static QWORD gCredGva = 0;
45 
49 static void *gCredMap1 = NULL;
50 
57 static void *gCredMap2 = NULL;
58 
62 char *gLibPaths[] =
63 {
64  "/lib/*",
65  "/lib64/*",
66  "/lib32/*",
67  "/usr/lib/*",
68  "/usr/lib32/*",
69  "/usr/lib64/*",
70  "/@/.snapshots/*/snapshots/lib64/*",
71  "/@/.snapshots/*/snapshots/lib32/*",
72  "/@/.snapshots/*/snapshots/lib/*",
73  "/@/.snapshots/*/snapshot/lib64/*",
74  "/@/.snapshots/*/snapshot/lib32/*",
75  "/@/.snapshots/*/snapshot/lib/*",
76 
77 };
78 
82 char *gLibFiles[] =
83 {
84  "libc-2.??.so",
85  "libpthread-2.??.so",
86 };
87 
88 
89 static void
91  void
92  )
96 {
97  if (NULL != gCredMap1)
98  {
100 
101  gCredMap1 = NULL;
102  }
103 
104  if (NULL != gCredMap2)
105  {
107 
108  gCredMap2 = NULL;
109  }
110 
111  gCredGva = 0;
112 }
113 
114 
115 
116 static INTSTATUS
118  _In_ QWORD CredGva
119  )
127 {
128  INTSTATUS status;
129 
130  status = IntVirtMemMap(CredGva, PAGE_REMAINING(CredGva), gGuest.Mm.SystemCr3, 0, &gCredMap1);
131  if (!INT_SUCCESS(status))
132  {
133  ERROR("[ERROR] IntVirtMemMap failed for %llx: %08x\n", CredGva, status);
134  goto _cleanup_and_fail;
135  }
136 
137  if (PAGE_COUNT(CredGva, LIX_FIELD(Cred, Sizeof)) > 1)
138  {
139  status = IntVirtMemMap((CredGva & PAGE_MASK) + PAGE_SIZE, PAGE_SIZE, gGuest.Mm.SystemCr3, 0, &gCredMap2);
140  if (!INT_SUCCESS(status))
141  {
142  ERROR("[ERROR] IntVirtMemMap failed for %llx: %08x\n", (CredGva & PAGE_MASK) + PAGE_SIZE, status);
143  goto _cleanup_and_fail;
144  }
145  }
146 
147  gCredGva = CredGva;
148 
149  return INT_STATUS_SUCCESS;
150 
151 _cleanup_and_fail:
153 
154  return status;
155 }
156 
157 
158 static void
160  _In_ const LIX_CREDS *Creds
161  )
167 {
168  INTSTATUS status;
169  INTERNAL_CRED *c = NULL;
170 
171  if (NULL == Creds)
172  {
173  return;
174  }
175 
176  status = IntVirtMemMap(Creds->Gva, sizeof(*c), gGuest.Mm.SystemCr3, 0, &c);
177  if (!INT_SUCCESS(status))
178  {
179  ERROR("[ERROR] IntVirtMemMap failed for gva %llx\n", Creds->Gva);
180  return;
181  }
182 
183  LOG("--> uid = %04d, guid = %04d, suid = %04d, sgid = %04d, euid = %04d, egid = %04d, fsuid = %04d, fsgid = %04d\n",
184  c->uid, c->guid, c->suid, c->sgid, c->euid, c->egid, c->fsuid, c->fsgid);
185 
186  IntVirtMemUnmap(&c);
187 }
188 
189 
190 static void
192  _In_ const LIX_TASK_OBJECT *Task
193  )
199 {
201  memzero(pEvent, sizeof(*pEvent));
202 
203  INTSTATUS status = IntKernVirtMemFetchQword(Task->Gva + LIX_FIELD(TaskStruct, Cred), &pEvent->BaseAddress);
204  if (!INT_SUCCESS(status))
205  {
206  ERROR("[ERROR] IntKernVirtMemFetchQword failed: 0x%08x\n", status);
207  }
208 
209  pEvent->VirtualAddress = pEvent->BaseAddress;
210  pEvent->Size = LIX_FIELD(Cred, Sizeof);
211 
212  pEvent->Header.Flags = ALERT_FLAG_LINUX;
213  pEvent->Header.Flags |= ALERT_FLAG_ASYNC;
214 
216  {
217  pEvent->Header.Flags = ALERT_FLAG_BETA;
218  }
219 
222  pEvent->Header.MitreID = idAccessToken;
223 
224  pEvent->Header.CpuContext.Valid = FALSE;
225  pEvent->Header.CurrentProcess.Valid = FALSE;
226 
227  IntAlertFillLixProcess(Task, &pEvent->Originator.Process);
228  IntAlertFillLixProcess(Task, &pEvent->Victim.Process);
229 
230  pEvent->Victim.Type = introObjectTypeCreds;
232 
234 
235  pEvent->WriteInfo.Size = 0;
236 
237  LOG("[CRED] [INTEGRITY VIOLATION] Modified credentials for process (%d %llx %s) at address %llx.\n",
238  Task->Pid, Task->Gva, Task->Comm, pEvent->VirtualAddress );
239  IntLixCredsDump(Task->Creds);
240  LOG("[CRED] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ROOTKIT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n");
241 
242  status = IntNotifyIntroEvent(introEventIntegrityViolation, pEvent, sizeof(*pEvent));
243  if (!INT_SUCCESS(status))
244  {
245  WARNING("[WARNING] IntNotifyIntroEvent failed: %08x\n", status);
246  }
247 
248 }
249 
250 
251 static DWORD
253  _In_ DWORD Offset,
254  _In_ DWORD Size,
255  _In_ DWORD InitialCrc
256  )
273 {
274  DWORD crc = InitialCrc;
275 
276  // Three cases:
277 
278  if ((gCredGva & PAGE_OFFSET) + Offset + Size < PAGE_SIZE)
279  {
280  return Crc32Compute((BYTE *)gCredMap1 + Offset, Size, crc);
281  }
282 
283  if ((gCredGva & PAGE_OFFSET) + Offset < PAGE_SIZE)
284  {
285  crc = Crc32Compute((BYTE *)gCredMap1 + Offset, PAGE_REMAINING(gCredGva + Offset), crc);
286 
287  return Crc32Compute((BYTE *)gCredMap2, (gCredGva + Offset + Size) & PAGE_OFFSET, crc);
288  }
289 
290  return Crc32Compute((BYTE *)gCredMap2 + ((gCredGva + Offset) & PAGE_OFFSET), Size, crc);
291 }
292 
293 
294 static INTSTATUS
296  _In_ QWORD CredGva,
297  _Out_ DWORD *Checksum
298  )
316 {
317  INTSTATUS status;
318  static DWORD range[4] = {DWORD_MAX};
319 
320  if (range[0] == DWORD_MAX)
321  {
322  if (LIX_FIELD(Cred, Usage) < LIX_FIELD(Cred, Rcu))
323  {
324  range[0] = LIX_FIELD(Cred, Usage);
325  range[1] = range[0] + 4;
326  range[2] = LIX_FIELD(Cred, Rcu);
327  range[3] = range[2] + 16;
328  }
329  else
330  {
331  range[0] = LIX_FIELD(Cred, Rcu);
332  range[1] = range[0] + 16;
333  range[2] = LIX_FIELD(Cred, Usage);
334  range[3] = range[2] + 4;
335  }
336  }
337 
338  status = IntLixCredInitMap(CredGva);
339  if (!INT_SUCCESS(status))
340  {
341  return status;
342  }
343 
344  *Checksum = INITIAL_CRC_VALUE;
345 
346  if (range[0] > 0)
347  {
348  *Checksum = IntLixCredCalculateCrc32Region(0, range[0], *Checksum);
349  }
350 
351  *Checksum = IntLixCredCalculateCrc32Region(range[1], range[2] - range[1], *Checksum);
352 
353  if (range[3] < LIX_FIELD(Cred, Sizeof))
354  {
355  *Checksum = IntLixCredCalculateCrc32Region(range[3], LIX_FIELD(Cred, Sizeof) - range[3], *Checksum);
356  }
357 
359 
360  return INT_STATUS_SUCCESS;
361 }
362 
363 
364 INTSTATUS
366  _In_ QWORD CredsGva,
367  _Out_ LIX_CREDS **Creds
368  )
381 {
382  INTSTATUS status;
383 
384  if (!IS_KERNEL_POINTER_LIX(CredsGva))
385  {
387  }
388 
389  if (NULL == Creds)
390  {
392  }
393 
394  *Creds = NULL;
395 
397  {
399  }
400 
401  list_for_each(gCreds, LIX_CREDS, pExtCreds)
402  {
403  if (CredsGva == pExtCreds->Gva)
404  {
405  // Maybe do an integrity check here?
406  pExtCreds->RefCount++;
407  *Creds = pExtCreds;
408 
409  return INT_STATUS_SUCCESS;
410  }
411  }
412 
413  LIX_CREDS *pCreds = HpAllocWithTag(sizeof(LIX_CREDS), IC_TAG_CRED);
414  if (NULL == pCreds)
415  {
417  }
418 
419  pCreds->Gva = CredsGva;
420  pCreds->RefCount = 1;
421 
422  status = IntLixCredCalculateChecksum(CredsGva, &pCreds->Checksum);
423  if (!INT_SUCCESS(status))
424  {
425  ERROR("[ERROR] IntLixCredCalculateChecksum failed for 0x%llx. Status: 0x%08x\n", CredsGva, status);
426 
428 
429  return status;
430  }
431 
432  InsertTailList(&gCreds, &pCreds->Link);
433 
434  *Creds = pCreds;
435 
436  return INT_STATUS_SUCCESS;
437 }
438 
439 
440 void
442  _In_ LIX_CREDS **Creds
443  )
452 {
453  LIX_CREDS *pCreds = *Creds;
454 
455  *Creds = NULL;
456 
457  if (NULL == pCreds)
458  {
459  return;
460  }
461 
462  if (pCreds->RefCount == 0)
463  {
464  ERROR("[ERROR] Refcount for creds %llx is already 0!\n", pCreds->Gva);
465  IntBugCheck();
466  }
467 
468  if (0 == --pCreds->RefCount)
469  {
470  RemoveEntryList(&pCreds->Link);
472  }
473 }
474 
475 
476 static INTSTATUS
478  _In_ LIX_CREDS *Creds,
479  _In_ BOOLEAN Update,
480  _Out_ BOOLEAN *Valid
481  )
494 {
495  INTSTATUS status;
496  DWORD checksum;
497 
499  {
500  *Valid = TRUE;
502  }
503 
504  if (NULL == Creds)
505  {
507  }
508 
509  status = IntLixCredCalculateChecksum(Creds->Gva, &checksum);
510  if (!INT_SUCCESS(status))
511  {
512  ERROR("[ERROR] IntLixCredCalculateChecksum failed for %llx (refcount: %d): 0x%08x\n",
513  Creds->Gva, Creds->RefCount, status);
514  return status;
515  }
516 
517  *Valid = TRUE;
518 
519  if (__unlikely(checksum != Creds->Checksum))
520  {
521  if (Update)
522  {
523  Creds->Checksum = checksum;
524  }
525 
526  *Valid = FALSE;
527  }
528 
529  return INT_STATUS_SUCCESS;
530 }
531 
532 
533 void
535  _In_ LIX_TASK_OBJECT *Task
536  )
542 {
543  BOOLEAN valid;
544 
546  {
547  return;
548  }
549 
550  if (NULL == Task->Creds)
551  {
552  return;
553  }
554 
555  INTSTATUS status = IntLixCredCheckIntegrity(Task->Creds, FALSE, &valid);
556  if (!INT_SUCCESS(status))
557  {
558  ERROR("[ERROR] IntLixCredCheckIntegrity failed for task '%s' (%d, 0x%llx)\n",
559  Task->ProcName, Task->Pid, Task->Gva);
560  return;
561  }
562 
563  if (valid)
564  {
565  return;
566  }
567 
569  {
570  Task->Dpi.StolenTokens = TRUE;
571  }
572 
574 }
575 
576 
577 static void
579  _In_ LIX_TASK_OBJECT *Task,
580  _Out_ INTRO_ACTION *Action,
581  _Out_ INTRO_ACTION_REASON *Reason
582  )
594 {
595  INTSTATUS status = INT_STATUS_SUCCESS;
596  LIX_TRAP_FRAME trapFrame = { 0 };
597  LIX_VMA vma = { 0 };
598  char *pFilePath = NULL;
599  DWORD len;
600 
601  *Action = introGuestNotAllowed;
602  *Reason = introReasonNoException;
603 
604  status = IntLixTaskGetTrapFrame(Task, &trapFrame);
605  if (!INT_SUCCESS(status))
606  {
607  ERROR("[ERROR] IntLixTaskGetTrapFrame failed with status: 0x%08x\n", status);
608 
609  *Action = introGuestNotAllowed;
610  *Reason = introReasonInternalError;
611 
612  return;
613  }
614 
615  status = IntLixMmFetchVma(Task, trapFrame.Rip, &vma);
616  if (!INT_SUCCESS(status))
617  {
618  ERROR("[ERROR] IntLixMmFetchVad failed for RIP %llx: %08x\n", trapFrame.Rip, status);
619 
620  *Action = introGuestNotAllowed;
621  *Reason = introReasonInternalError;
622 
623  return;
624  }
625 
626  status = IntLixFileGetPath(vma.File, &pFilePath, &len);
627  if (status == INT_STATUS_INVALID_DATA_SIZE)
628  {
629  *Action = introGuestNotAllowed;
630  *Reason = introReasonInternalError;
631  }
632  else if (!INT_SUCCESS(status))
633  {
634  ERROR("[ERROR] IntLixFileGetPath filed for file @ 0x%016llx : %08x\n", vma.File, status);
635  }
636  else if (pFilePath)
637  {
638  char *pFileName = NULL;
639  BOOLEAN found = FALSE;
640 
641  for (DWORD i = 0; i < ARRAYSIZE(gLibPaths); i++)
642  {
643  if (glob_match_utf8(gLibPaths[i], pFilePath, FALSE, FALSE))
644  {
645  found = TRUE;
646  break;
647  }
648  }
649 
650  if (!found)
651  {
652  goto _out;
653  }
654 
655  for (; len > 0; len--)
656  {
657  if (pFilePath[len] == '/')
658  {
659  pFileName = &pFilePath[len + 1];
660  break;
661  }
662  }
663 
664  if (NULL == pFileName)
665  {
666  pFileName = pFilePath;
667  }
668 
669  for (DWORD i = 0; i < ARRAYSIZE(gLibFiles); i++)
670  {
671  if (glob_match_utf8(gLibFiles[i], pFileName, FALSE, FALSE))
672  {
673  found = TRUE;
674  break;
675  }
676  }
677 
678  if (found)
679  {
680  *Action = introGuestAllowed;
681  *Reason = introReasonAllowed;
682  }
683  }
684 
685 _out:
686  if (*Action != introGuestAllowed)
687  {
688  LOG("[WARNING] [LIX-CRED] Return address is inside '%s'\n", pFilePath);
689  }
690 }
691 
692 
693 INTSTATUS
695  _In_ void *Detour
696  )
714 {
715  INTSTATUS status;
716  LIX_CREDS *newCreds = NULL;
717 
718  UNREFERENCED_PARAMETER(Detour);
719 
721  if (NULL == pTask)
722  {
723  ERROR("[ERROR] IntLixTaskGetCurrent returned NULL\n");
724  return INT_STATUS_SUCCESS;
725  }
726 
727  if (pTask->KernelMode)
728  {
729  return INT_STATUS_SUCCESS;
730  }
731 
732  if (LIX_FIELD(Info, CredAltered))
733  {
734  DWORD in;
735 
736  status = IntKernVirtMemFetchDword(pTask->Gva + LIX_FIELD(TaskStruct, InExecve), &in);
737  if (!INT_SUCCESS(status))
738  {
739  ERROR("[ERROR] IntKernVirtMemFetchDword failed for %llx with status: %08x\n",
740  pTask->Gva + LIX_FIELD(TaskStruct, InExecve), status);
741  }
742  else if (0 == (in & BIT(LIX_FIELD(TaskStruct, InExecveBit))))
743  {
744  // We should make one last check to be sure they haven't changed in the meantime
745  IntLixCredsVerify(pTask);
746  }
747  }
748  else
749  {
750  IntLixCredsVerify(pTask);
751  }
752 
753  status = IntLixCredAdd(gVcpu->Regs.R9, &newCreds);
754  if (!INT_SUCCESS(status))
755  {
756  ERROR("[ERROR] IntLixCredAdd failed for %s (%d 0x%llx). Status: 0x%08x\n",
757  pTask->Comm, pTask->Pid, pTask->Gva, status);
758  }
759 
760  IntLixCredRemove(&pTask->Creds);
761  pTask->Creds = newCreds;
762 
763  return INT_STATUS_SUCCESS;
764 }
unsigned int euid
Definition: lixcred.c:29
enum _INTRO_ACTION_REASON INTRO_ACTION_REASON
The reason for which an INTRO_ACTION was taken.
#define __unlikely(x)
Definition: common.h:64
_Bool BOOLEAN
Definition: intro_types.h:58
#define _Out_
Definition: intro_sal.h:22
#define INTRO_OPT_PROT_DPI_TOKEN_STEAL
Enable process creation protection for stolen token.
Definition: intro_types.h:492
BOOLEAN Valid
Set to True if the information in the structure is valid, False otherwise.
Definition: intro_types.h:904
INTSTATUS IntVirtMemUnmap(void **HostPtr)
Unmaps a memory range previously mapped with IntVirtMemMap.
Definition: introcore.c:2234
DWORD Size
The size of the access.
Definition: intro_types.h:982
static void * gCredMap1
The mapping point of the cred structure.
Definition: lixcred.c:49
An internal error occurred (no memory, pages not present, etc.).
Definition: intro_types.h:195
uint8_t BYTE
Definition: intro_types.h:47
unsigned int uid
Definition: lixcred.c:25
IG_ARCH_REGS Regs
The current state of the guest registers.
Definition: guests.h:95
DWORD Crc32Compute(const void *Buffer, size_t Size, DWORD InitialCrc)
Computes the CRC for a byte array.
Definition: crc32.c:103
static QWORD gCredGva
The guest virtual address of the "struct cred" that is currently being mapped.
Definition: lixcred.c:44
#define _In_
Definition: intro_sal.h:21
MITRE_ID MitreID
The Mitre ID that corresponds to this attack.
Definition: intro_types.h:1199
QWORD SystemCr3
The Cr3 used to map the kernel.
Definition: guests.h:211
#define INT_STATUS_SUCCESS
Definition: introstatus.h:54
#define BIT(x)
Definition: common.h:68
BOOLEAN glob_match_utf8(char const *Pattern, char const *String, BOOLEAN IgnoreCase, BOOLEAN Truncated)
Definition: introcrt.c:609
#define PAGE_REMAINING(addr)
Definition: pgtable.h:163
Event structure for integrity violations on monitored structures.
Definition: intro_types.h:1572
QWORD Gva
The guest virtual address of the task_struct.
Definition: lixprocess.h:42
void IntLixCredsVerify(LIX_TASK_OBJECT *Task)
Verifies whether the credentials of a process has been altered or not.
Definition: lixcred.c:534
The beginning of the cred structure as defined by linux kernel.
Definition: lixcred.c:21
#define INT_SUCCESS(Status)
Definition: introstatus.h:42
QWORD Flags
A combination of ALERT_FLAG_* values describing the alert.
Definition: intro_types.h:1198
INTRO_OBJECT_TYPE Type
Definition: intro_types.h:1589
Access &#39;struct creds&#39; fields.
Definition: intro_types.h:251
#define PAGE_OFFSET
Definition: pgtable.h:32
The action was not allowed because there was no reason to allow it.
Definition: intro_types.h:183
#define ARRAYSIZE(A)
Definition: introdefs.h:101
BOOLEAN KernelBetaDetections
True if the kernel protection is in beta (log-only) mode.
Definition: guests.h:303
struct _EVENT_INTEGRITY_VIOLATION::@304 Victim
DWORD RefCount
Number of processes referring this credentials set.
Definition: lixcred.h:17
#define INT_STATUS_NOT_NEEDED_HINT
Definition: introstatus.h:317
#define ERROR(fmt,...)
Definition: glue.h:62
#define ALERT_FLAG_ASYNC
If set, the alert was generated in an async manner.
Definition: intro_types.h:675
#define INTRO_OPT_PROT_KM_CREDS
Definition: intro_types.h:417
#define HpAllocWithTag(Len, Tag)
Definition: glue.h:516
int INTSTATUS
The status data type.
Definition: introstatus.h:24
#define PAGE_COUNT(addr, bytes)
Definition: pgtable.h:189
#define ALERT_FLAG_LINUX
Definition: intro_types.h:676
DWORD Checksum
The CRC32 checksum.
Definition: lixcred.h:18
#define LOG(fmt,...)
Definition: glue.h:61
unsigned int fsgid
Definition: lixcred.c:32
void IntAlertFillVersionInfo(INTRO_VIOLATION_HEADER *Header)
Fills version information for an alert.
Definition: alerts.c:327
static void IntLixCredAnalyzeStack(LIX_TASK_OBJECT *Task, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason)
Analyze the user mode stack of a process that is patching it&#39;s credentials.
Definition: lixcred.c:578
static void IntLixCredsDump(const LIX_CREDS *Creds)
Logs information about a cred structure.
Definition: lixcred.c:159
Access Token Manipulation.
Definition: intro_types.h:1153
INTRO_ACTION_REASON Reason
The reason for which Action was taken.
Definition: intro_types.h:1195
#define ALERT_FLAG_BETA
If set, the alert is a BETA alert. No action was taken.
Definition: intro_types.h:671
GENERIC_ALERT gAlert
Global alert buffer.
Definition: alerts.c:27
INTSTATUS IntKernVirtMemFetchDword(QWORD GuestVirtualAddress, DWORD *Data)
Reads 4 bytes from the guest kernel memory.
Definition: introcore.c:829
#define INITIAL_CRC_VALUE
Definition: introdefs.h:221
static DWORD IntLixCredCalculateCrc32Region(DWORD Offset, DWORD Size, DWORD InitialCrc)
Calculates the CRC32 checksum for a memory region representing a slice of the cred structure...
Definition: lixcred.c:252
DWORD Size
The size of the modified memory area.
Definition: intro_types.h:1618
unsigned int sgid
Definition: lixcred.c:28
Describes one set of credentials.
Definition: lixcred.h:13
void IntLixCredRemove(LIX_CREDS **Creds)
Removes the integrity protection for the credentials set that belong to a process.
Definition: lixcred.c:441
INTSTATUS IntLixMmFetchVma(LIX_TASK_OBJECT *Task, QWORD Address, LIX_VMA *Vma)
Retrieve information about a VMA structure containing a user mode address.
Definition: lixmm.c:581
#define IS_KERNEL_POINTER_LIX(p)
Definition: lixguest.h:11
INTSTATUS IntKernVirtMemFetchQword(QWORD GuestVirtualAddress, QWORD *Data)
Reads 8 bytes from the guest kernel memory.
Definition: introcore.c:811
INTRO_CPUCTX CpuContext
The context of the CPU that triggered the alert.
Definition: intro_types.h:1196
__noreturn void IntBugCheck(void)
Definition: glue.c:917
INTSTATUS IntNotifyIntroEvent(INTRO_EVENT_TYPE EventClass, void *Param, size_t EventSize)
Notifies the integrator about an introspection alert.
Definition: glue.c:1042
static BOOLEAN RemoveEntryList(LIST_ENTRY *Entry)
Definition: introlists.h:87
#define memzero(a, s)
Definition: introcrt.h:35
unsigned long long QWORD
Definition: intro_types.h:53
QWORD Current
The currently used options.
Definition: guests.h:236
QWORD VirtualAddress
The guest virtual address which was modified.
Definition: intro_types.h:1616
#define TRUE
Definition: intro_types.h:30
INTRO_VIOLATION_HEADER Header
The alert header.
Definition: intro_types.h:1574
INTSTATUS IntLixCredAdd(QWORD CredsGva, LIX_CREDS **Creds)
Adds a cred structure in the integrity protected credentials list.
Definition: lixcred.c:365
#define LIX_FIELD(Structure, Field)
Macro used to access fields inside the LIX_OPAQUE_FIELDS structure.
Definition: lixguest.h:429
#define HpFreeAndNullWithTag(Add, Tag)
Definition: glue.h:517
struct _INTERNAL_CRED INTERNAL_CRED
The beginning of the cred structure as defined by linux kernel.
INTSTATUS IntLixCommitCredsHandle(void *Detour)
Detour handler for "commit_creds" function.
Definition: lixcred.c:694
static void InsertTailList(LIST_ENTRY *ListHead, LIST_ENTRY *Entry)
Definition: introlists.h:135
char * gLibPaths[]
Directories where libraries changing credentials should be located.
Definition: lixcred.c:62
#define WARNING(fmt,...)
Definition: glue.h:60
#define VICTIM_PROCESS_CREDENTIALS
Printable name used for introObjectTypeCreds objects.
Definition: intro_types.h:743
#define PAGE_SIZE
Definition: common.h:70
static LIST_HEAD gCreds
The list head of the credentials structures protected by introcore.
Definition: lixcred.c:39
DWORD KernelMode
TRUE if this process/thread is inside kernel mode.
Definition: lixprocess.h:97
#define UNREFERENCED_PARAMETER(P)
Definition: introdefs.h:29
QWORD Gva
Guest virtual address of the protected cred structure.
Definition: lixcred.h:16
WCHAR Name[ALERT_PATH_MAX_LEN]
NULL-terminated string with a human readable description of the modified object.
Definition: intro_types.h:1591
uint32_t DWORD
Definition: intro_types.h:49
BOOLEAN Valid
Set to True if the information in the structure is valid, False otherwise.
Definition: intro_types.h:965
LIX_CREDS * Creds
The LIX_CREDS reference for the credentials of this process.
Definition: lixprocess.h:105
enum _INTRO_ACTION INTRO_ACTION
Event actions.
INTSTATUS IntLixTaskGetTrapFrame(const LIX_TASK_OBJECT *Task, LIX_TRAP_FRAME *TrapFrame)
Retrieves the trap frame for a Linux task.
Definition: lixprocess.c:1098
INTRO_WRITE_INFO WriteInfo
Definition: intro_types.h:1607
static void * gCredMap2
The secondary mapping point of the cred structure.
Definition: lixcred.c:57
#define DWORD_MAX
Definition: introtypes.h:33
__must_check INTSTATUS IntVirtMemMap(QWORD Gva, DWORD Length, QWORD Cr3, DWORD Flags, void **HostPtr)
Maps a guest virtual memory range inside Introcore virtual address space.
Definition: introcore.c:2134
MM Mm
Guest memory information, such as paging mode, system Cr3 value, etc.
Definition: guests.h:374
char Comm[LIX_COMM_SIZE]
The short name of the executable.
Definition: lixprocess.h:44
static void IntLixTaskSendCredViolationEvent(const LIX_TASK_OBJECT *Task)
Sends an EVENT_INTEGRITY_VIOLATION event.
Definition: lixcred.c:191
GUEST_STATE gGuest
The current guest state.
Definition: guests.c:50
DWORD Pid
The task PID.
Definition: lixprocess.h:72
EVENT_INTEGRITY_VIOLATION Integrity
Definition: alerts.h:23
struct _EVENT_INTEGRITY_VIOLATION::@302 Originator
INTRO_ACTION Action
The action that was taken as the result of this alert.
Definition: intro_types.h:1194
Definition: lixmm.h:14
QWORD BaseAddress
The guest virtual address at which the monitored integrity region starts.
Definition: intro_types.h:1614
char * gLibFiles[]
Libraries allowed to change process credentials.
Definition: lixcred.c:82
#define LIST_HEAD_INIT(Name)
Definition: introlists.h:39
static INTSTATUS IntLixCredCheckIntegrity(LIX_CREDS *Creds, BOOLEAN Update, BOOLEAN *Valid)
Checks if the credentials have been altered.
Definition: lixcred.c:477
INTRO_PROCESS Process
The module to which the current code return to.
Definition: intro_types.h:1579
LIX_TASK_OBJECT * IntLixTaskFindByGva(QWORD TaskStruct)
Finds Linux process with the provided "task_struct" guest virtual address.
Definition: lixprocess.c:1025
#define INT_STATUS_INVALID_PARAMETER_1
Definition: introstatus.h:62
INTRO_PROCESS CurrentProcess
The current process.
Definition: intro_types.h:1197
VCPU_STATE * gVcpu
The state of the current VCPU.
Definition: guests.c:59
The action was blocked because there was no exception for it.
Definition: intro_types.h:189
unsigned int suid
Definition: lixcred.c:27
Sent for integrity violation alerts. See EVENT_INTEGRITY_VIOLATION.
Definition: intro_types.h:92
static INTSTATUS IntLixCredInitMap(QWORD CredGva)
Maps a cred structure in order to calculate the checksum in a faster manner.
Definition: lixcred.c:117
static void IntLixCredUninitMap(void)
Unmaps the cred structure previously mapped by IntLixCredInitMap.
Definition: lixcred.c:90
LIST_ENTRY Link
Linked list entry.
Definition: lixcred.h:15
unsigned int egid
Definition: lixcred.c:30
#define IC_TAG_CRED
Linux cred struct.
Definition: memtags.h:129
#define list_for_each(_head, _struct_type, _var)
Definition: introlists.h:41
void IntAlertFillLixProcess(const LIX_TASK_OBJECT *Task, INTRO_PROCESS *EventProcess)
Saves information about a Linux process inside an event.
Definition: alerts.c:1264
#define PAGE_MASK
Definition: pgtable.h:35
#define INT_STATUS_INVALID_PARAMETER_2
Definition: introstatus.h:65
INTRO_PROT_OPTIONS CoreOptions
The activation and protection options for this guest.
Definition: guests.h:271
static INTSTATUS IntLixCredCalculateChecksum(QWORD CredGva, DWORD *Checksum)
Calculates the CRC32 checksum for a cred structure.
Definition: lixcred.c:295
unsigned int fsuid
Definition: lixcred.c:31
#define INT_STATUS_INVALID_DATA_SIZE
Definition: introstatus.h:142
QWORD File
The Gva of the file this VMA maps to. Can be 0 which means this VMA is not a memory mapped file...
Definition: lixmm.h:23
unsigned int guid
Definition: lixcred.c:26
INTSTATUS IntLixFileGetPath(QWORD FileStructGva, char **Path, DWORD *Length)
Gets the path that corresponds to the provided FileStructGva (guest virtual address of the &#39;struct fi...
Definition: lixfiles.c:352
#define FALSE
Definition: intro_types.h:34
#define INT_STATUS_INSUFFICIENT_RESOURCES
Definition: introstatus.h:281