Skip to content

Instantly share code, notes, and snippets.

@mouseos
Created September 20, 2022 02:05
Show Gist options
  • Save mouseos/d5e652a4c3402b03aa7c2fc93db28aca to your computer and use it in GitHub Desktop.
Save mouseos/d5e652a4c3402b03aa7c2fc93db28aca to your computer and use it in GitHub Desktop.
int * prepare_kernel_cred(long param_1)
{
char cVar1;
bool bVar2;
int iVar3;
int *__dest;
int *__src;
int *piVar4;
__dest = (int *)kmem_cache_alloc(DAT_ffffff80092dfec8,0x14000c0);
if (__dest == (int *)0x0) {
return (int *)0x0;
}
if (param_1 == 0) {
__src = &DAT_ffffff80091d53f0;
Hint_Prefetch(0xffffff80091d53f0,2,0,1);
do {
cVar1 = '\x01';
bVar2 = (bool)ExclusiveMonitorPass(0xffffff80091d53f0,0x10);
if (bVar2) {
cVar1 = ExclusiveMonitorsStatus();
DAT_ffffff80091d53f0 = DAT_ffffff80091d53f0 + 1;
}
} while (cVar1 != '\0');
}
else {
__src = (int *)get_task_cred(param_1);
}
memcpy(__dest,__src,0xa8);
piVar4 = *(int **)(__dest + 0x20);
*__dest = 1;
Hint_Prefetch(piVar4,2,0,1);
do {
cVar1 = '\x01';
bVar2 = (bool)ExclusiveMonitorPass(piVar4,0x10);
if (bVar2) {
*piVar4 = *piVar4 + 1;
cVar1 = ExclusiveMonitorsStatus();
}
} while (cVar1 != '\0');
piVar4 = *(int **)(__dest + 0x24);
Hint_Prefetch(piVar4,2,0,1);
do {
cVar1 = '\x01';
bVar2 = (bool)ExclusiveMonitorPass(piVar4,0x10);
if (bVar2) {
*piVar4 = *piVar4 + 1;
cVar1 = ExclusiveMonitorsStatus();
}
} while (cVar1 != '\0');
*(undefined *)(__dest + 0x14) = 1;
*(undefined8 *)(__dest + 0x16) = 0;
*(undefined8 *)(__dest + 0x18) = 0;
*(undefined8 *)(__dest + 0x1a) = 0;
*(undefined8 *)(__dest + 0x1c) = 0;
*(undefined8 *)(__dest + 0x1e) = 0;
iVar3 = security_prepare_creds(__dest,__src,0x14000c0);
if (iVar3 < 0) {
Hint_Prefetch(__dest,2,0,1);
do {
iVar3 = *__dest;
cVar1 = '\x01';
bVar2 = (bool)ExclusiveMonitorPass(__dest,0x10);
if (bVar2) {
*__dest = iVar3 + -1;
cVar1 = ExclusiveMonitorsStatus();
}
} while (cVar1 != '\0');
DataMemoryBarrier(2,3);
if (iVar3 + -1 == 0) {
__put_cred(__dest);
}
Hint_Prefetch(__src,2,0,1);
do {
iVar3 = *__src;
cVar1 = '\x01';
bVar2 = (bool)ExclusiveMonitorPass(__src,0x10);
if (bVar2) {
*__src = iVar3 + -1;
cVar1 = ExclusiveMonitorsStatus();
}
} while (cVar1 != '\0');
DataMemoryBarrier(2,3);
if (iVar3 + -1 != 0) {
return (int *)0x0;
}
__dest = (int *)0x0;
}
else {
Hint_Prefetch(__src,2,0,1);
do {
iVar3 = *__src;
cVar1 = '\x01';
bVar2 = (bool)ExclusiveMonitorPass(__src,0x10);
if (bVar2) {
*__src = iVar3 + -1;
cVar1 = ExclusiveMonitorsStatus();
}
} while (cVar1 != '\0');
DataMemoryBarrier(2,3);
if (iVar3 + -1 != 0) {
return __dest;
}
}
__put_cred(__src);
return __dest;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment