Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There seems a bug with multicore #8

Open
ajax4sec opened this issue Feb 9, 2018 · 2 comments
Open

There seems a bug with multicore #8

ajax4sec opened this issue Feb 9, 2018 · 2 comments

Comments

@ajax4sec
Copy link

ajax4sec commented Feb 9, 2018

There seems a bug with multi-core in IoCpuIpiDpc function of DriverIo.cpp. I tested the Sysarg2 of the function and found it is not null. So the arg would be dereferenced by ObDereferenceObject(SysArg2), which would cause the error of reference_of_pointer with a blue screen.
I am not sure I was right and welcome with the discussion.

@howknows
Copy link

howknows commented Feb 9, 2018

Yes you are right!

for (int iCpuNum = 0, cpurefcount = 0; iCpuNum < sizeof(kTargetCpusAffinity) * 8; iCpuNum++) {
if (!(kTargetCpusAffinity & (1i64 << iCpuNum))) continue;
// Allocate and run the DPC
RtlZeroMemory(pIpiDpcStruct, sizeof(IPI_DPC_STRUCT));
pIpiDpcStruct->dwCpu = iCpuNum;
pIpiDpcStruct->Type = DPC_TYPE_START_PT;
KeInitializeEvent(&pIpiDpcStruct->kEvt, SynchronizationEvent, FALSE);
KeInitializeDpc(pkDpc, IoCpuIpiDpc, (PVOID)pIpiDpcStruct);
KeSetTargetProcessorDpc(pkDpc, (CCHAR)iCpuNum);
if (!cpurefcount)//Do not call ObfDereferenceObject too many, mul CPUs will cause BSOD. Just need call ObfDereferenceObject once!
KeInsertQueueDpc(pkDpc, (LPVOID)ptTraceStruct, (LPVOID)epTarget); // Method-Buffered: passing ptTraceStruct is safe
else
KeInsertQueueDpc(pkDpc ,(LPVOID)ptTraceStruct ,NULL);
cpurefcount++;
// Wait for the DPC to do its job
KeWaitForSingleObject((PVOID)&pIpiDpcStruct->kEvt, Executive, KernelMode, FALSE, NULL);
ntStatus = pIpiDpcStruct->ioSb.Status;
if (!NT_SUCCESS(ntStatus)) break;
}

@moflow
Copy link
Contributor

moflow commented Feb 11, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants