redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests
This commit is contained in:
1 parent
4add6789ba
commit
f882d339fb
232 files changed
+20934
-8898
No files matched your search
+76
-16
@@ -4,7 +4,7 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <kernel/hal/hal_api.h>
|
||||
#include <kernel/ke_apc.h>
|
||||
#include <kernel/ke_cpu.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <kernel/ke_thread.h>
|
||||
#include <kernel/ke_process.h>
|
||||
#include <kernel/io_file.h>
|
||||
#include <kernel/ke_system_root.h>
|
||||
#include <kernel/io_dma.h>
|
||||
#include <ntlite/ddi/io_driver.h>
|
||||
#include <kernel/ke_trap.h>
|
||||
@@ -1152,10 +1153,15 @@ static void KiRunStringViewSelfTest(void) {
|
||||
if (SysSvCopyZ(copy, 4, emb))
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "STRINGVIEW selftest: undersized copy unexpectedly succeeded\n");
|
||||
|
||||
// Paths are string views at the ABI boundary, but FAT/VFS path names do not
|
||||
// Paths are string views at the ABI boundary, but provider path names do not
|
||||
// accept embedded NUL bytes. This must fail before reaching any filesystem.
|
||||
IO_VOLUME* volume = (IO_VOLUME*)0;
|
||||
KSTATUS s = KeReferenceSystemRootVolume(&volume);
|
||||
if (!KSUCCESS(s))
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "STRINGVIEW selftest: system volume reference status=%u\n", s);
|
||||
FILE_OBJECT* f = (FILE_OBJECT*)0;
|
||||
KSTATUS s = IoOpenFile(SysSvFromParts("system/init.exe\0junk", 20), &f);
|
||||
s = IoOpenFileAtVolume(volume, SysSvFromParts("system/init.exe\0junk", 20), &f);
|
||||
IoReleaseVolume(volume);
|
||||
if (s != NTLSTATUS_INVALID_PARAMETER)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "STRINGVIEW selftest: embedded-NUL path status=%u\n", s);
|
||||
|
||||
@@ -1164,6 +1170,59 @@ static void KiRunStringViewSelfTest(void) {
|
||||
DbgPrint("STRINGVIEW selftest: PASS\n");
|
||||
}
|
||||
|
||||
// Capability-relative native-path self-test.
|
||||
static void KiRunVolumeRelativePathSelfTest(void) {
|
||||
DbgPrint("VOLUME/PATH selftest: begin\n");
|
||||
|
||||
IO_VOLUME* volume = (IO_VOLUME*)0;
|
||||
KSTATUS status = KeReferenceSystemRootVolume(&volume);
|
||||
if (!KSUCCESS(status))
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "VOLUME/PATH selftest: system volume reference failed %u\n", status);
|
||||
|
||||
FILE_OBJECT* file = (FILE_OBJECT*)0;
|
||||
status = IoOpenFileAtVolume(volume, SYS_SV_LITERAL("system/init.exe"), &file);
|
||||
if (!KSUCCESS(status) || !file)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "VOLUME/PATH selftest: direct open failed %u\n", status);
|
||||
IoCloseFile(file);
|
||||
|
||||
const SYS_STRING_VIEW invalidPaths[] = {
|
||||
SYS_SV_LITERAL("/system/init.exe"),
|
||||
SYS_SV_LITERAL("system\\init.exe"),
|
||||
SYS_SV_LITERAL("system//init.exe"),
|
||||
SYS_SV_LITERAL("system/./init.exe"),
|
||||
SYS_SV_LITERAL("system/../init.exe"),
|
||||
SYS_SV_LITERAL("system/init.exe/"),
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(invalidPaths) / sizeof(invalidPaths[0]); ++i) {
|
||||
file = (FILE_OBJECT*)0;
|
||||
status = IoOpenFileAtVolume(volume, invalidPaths[i], &file);
|
||||
if (status != NTLSTATUS_INVALID_PARAMETER || file)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST,
|
||||
"VOLUME/PATH selftest: invalid path %llu status=%u file=0x%016llX\n",
|
||||
(uint64_t)i, status, (uint64_t)(uintptr_t)file);
|
||||
}
|
||||
|
||||
DIR_OBJECT* directory = (DIR_OBJECT*)0;
|
||||
status = IoOpenDirAtVolume(volume, SYS_SV_LITERAL("system"), &directory);
|
||||
if (!KSUCCESS(status) || !directory)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "VOLUME/PATH selftest: directory open failed %u\n", status);
|
||||
|
||||
file = (FILE_OBJECT*)0;
|
||||
status = IoOpenFileAtDirectory(directory, SYS_SV_LITERAL("init.exe"), &file);
|
||||
if (!KSUCCESS(status) || !file)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "VOLUME/PATH selftest: directory-relative open failed %u\n", status);
|
||||
IoCloseFile(file);
|
||||
|
||||
file = (FILE_OBJECT*)0;
|
||||
status = IoOpenFileAtDirectory(directory, SYS_SV_LITERAL("../init.exe"), &file);
|
||||
if (status != NTLSTATUS_INVALID_PARAMETER || file)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "VOLUME/PATH selftest: parent traversal status=%u\n", status);
|
||||
|
||||
IoCloseDir(directory);
|
||||
IoReleaseVolume(volume);
|
||||
DbgPrint("VOLUME/PATH selftest: PASS\n");
|
||||
}
|
||||
|
||||
// Async file I/O self-test.
|
||||
|
||||
typedef struct KI_FILE_ASYNC_SELFTEST_STATE {
|
||||
@@ -1221,7 +1280,7 @@ static void KiRunAsyncFileIoSelfTest(void) {
|
||||
memset(&st, 0, sizeof(st));
|
||||
st.Iosb.Status = NTLSTATUS_FAILURE;
|
||||
|
||||
KSTATUS s = IoOpenFile(SYS_SV_LITERAL("system/init.exe"), &st.File);
|
||||
KSTATUS s = KeOpenSystemRootFile("system/init.exe", &st.File);
|
||||
if (!KSUCCESS(s)) {
|
||||
DbgPrint("FILE/ASYNC selftest: SKIP, system/init.exe open failed %u\n", s);
|
||||
return;
|
||||
@@ -1303,8 +1362,8 @@ static void KiRunAsyncFileIoSelfTest(void) {
|
||||
wiosb.Status = NTLSTATUS_FAILURE;
|
||||
wiosb.Information = 0;
|
||||
|
||||
(void)IoDeleteFile(SYS_SV_LITERAL("asyncio.tmp"));
|
||||
s = IoCreateFile(SYS_SV_LITERAL("asyncio.tmp"), &wf);
|
||||
(void)KeDeleteSystemRootFile("asyncio.tmp");
|
||||
s = KeCreateSystemRootFile("asyncio.tmp", &wf);
|
||||
if (!KSUCCESS(s))
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "FILE/ASYNC selftest: create write temp failed %u\n", s);
|
||||
|
||||
@@ -1343,7 +1402,7 @@ static void KiRunAsyncFileIoSelfTest(void) {
|
||||
IoCloseFile(wf);
|
||||
wf = (FILE_OBJECT*)0;
|
||||
|
||||
s = IoOpenFile(SYS_SV_LITERAL("asyncio.tmp"), &rf);
|
||||
s = KeOpenSystemRootFile("asyncio.tmp", &rf);
|
||||
if (!KSUCCESS(s))
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "FILE/ASYNC selftest: reopen write temp failed %u\n", s);
|
||||
|
||||
@@ -1357,7 +1416,7 @@ static void KiRunAsyncFileIoSelfTest(void) {
|
||||
|
||||
IoCloseFile(rf);
|
||||
ObDereferenceObject(&wev->Header);
|
||||
s = IoDeleteFile(SYS_SV_LITERAL("asyncio.tmp"));
|
||||
s = KeDeleteSystemRootFile("asyncio.tmp");
|
||||
if (!KSUCCESS(s))
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "FILE/ASYNC selftest: delete temp failed %u\n", s);
|
||||
|
||||
@@ -1774,16 +1833,16 @@ void KiRunCoreHardeningSelfTests(void) {
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: GS/KCPU self pointer mismatch self=0x%016llX cpu=0x%016llX\n",
|
||||
(uint64_t)cpu->Self, (uint64_t)cpu);
|
||||
if (KeGetCurrentCpuIndex() != 0)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: current CPU index is not BSP/0\n");
|
||||
if (cpu->State != KeCpuOnline || !cpu->IsBsp)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: BSP lifecycle invalid state=%ld bsp=%u\n",
|
||||
cpu->State, cpu->IsBsp);
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: current CPU index is not boot processor/0\n");
|
||||
if (cpu->State != KeCpuOnline || !cpu->IsBootProcessor)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: boot-processor lifecycle invalid state=%ld boot=%u\n",
|
||||
cpu->State, cpu->IsBootProcessor);
|
||||
if (KeGetCurrentIrql() != PASSIVE_LEVEL)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: expected PASSIVE_LEVEL, got %u\n", KeGetCurrentIrql());
|
||||
if (KeGetCurrentTss() != &cpu->Tss)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: current TSS is not CPU-local\n");
|
||||
if (!cpu->Tss.RSP0 || cpu->Tss.IoMapBase != sizeof(TSS64))
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: invalid BSP TSS rsp0=0x%016llX iomap=%u\n",
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: invalid boot-processor TSS rsp0=0x%016llX iomap=%u\n",
|
||||
cpu->Tss.RSP0, cpu->Tss.IoMapBase);
|
||||
if (!cpu->Gdtr.Base || cpu->Gdtr.Base != (uint64_t)cpu->Gdt)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: GDT is not CPU-local base=0x%016llX gdt=0x%016llX\n",
|
||||
@@ -1793,10 +1852,10 @@ void KiRunCoreHardeningSelfTests(void) {
|
||||
KCPU* ap = &gCpus[i];
|
||||
if (ap->State == KeCpuAbsent)
|
||||
continue;
|
||||
if (ap->State != KeCpuOnline || ap->IsBsp)
|
||||
if (ap->State != KeCpuOnline || ap->IsBootProcessor)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST,
|
||||
"CORE selftest: AP%u lifecycle invalid state=%ld bsp=%u\n",
|
||||
i, ap->State, ap->IsBsp);
|
||||
"CORE selftest: AP%u lifecycle invalid state=%ld boot=%u\n",
|
||||
i, ap->State, ap->IsBootProcessor);
|
||||
if (!ap->KernelStack || !ap->KernelStackTop)
|
||||
KePanic(KE_PANIC_CODE_SELFTEST, "CORE selftest: AP%u missing kernel stack\n", i);
|
||||
if (!ap->Tss.RSP0 || ap->Tss.IoMapBase != sizeof(TSS64))
|
||||
@@ -1847,6 +1906,7 @@ void KiRunKernelSelfTests(const HAL_API* hal) {
|
||||
KiRunVadCopyOnWriteSelfTest();
|
||||
KiRunVadSwapSelfTest();
|
||||
KiRunStringViewSelfTest();
|
||||
KiRunVolumeRelativePathSelfTest();
|
||||
KiRunIrpKernelApcSelfTest(hal);
|
||||
KiRunAsyncFileIoSelfTest();
|
||||
KiRunTrapFrameSelfTest();
|
||||
|
||||
Reference in new issue
Block a user