Updated fltmgr.sys-FltBuildDefaultSecurityDescriptor patchset

This commit is contained in:
Alistair Leslie-Hughes 2023-10-30 07:31:31 +11:00
parent 28180a60fd
commit e9a4c9a06f
3 changed files with 37 additions and 22 deletions

View File

@ -1,7 +1,7 @@
From 2a8ffcea70c41f013660d2b6168ab694c70246c0 Mon Sep 17 00:00:00 2001
From 8caf8262a8ae8b5f0275172a62d807240d86968d Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sun, 29 Aug 2021 13:26:53 +1000
Subject: [PATCH] fltmgr.sys: Implement FltBuildDefaultSecurityDescriptor
Subject: [PATCH 1/3] fltmgr.sys: Implement FltBuildDefaultSecurityDescriptor
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
@ -45,7 +45,7 @@ index 39ce6798178..8943b9f85cf 100644
@ stub FltGetBottomInstance
@ stub FltGetContexts
diff --git a/dlls/fltmgr.sys/main.c b/dlls/fltmgr.sys/main.c
index e1016a4989c..68f242ab8e8 100644
index e1016a4989c..9a85f4b6c82 100644
--- a/dlls/fltmgr.sys/main.c
+++ b/dlls/fltmgr.sys/main.c
@@ -23,7 +23,6 @@
@ -132,9 +132,8 @@ index e1016a4989c..68f242ab8e8 100644
+
+void WINAPI FltFreeSecurityDescriptor(PSECURITY_DESCRIPTOR descriptor)
+{
+ RtlFreeHeap(GetProcessHeap(), 0, descriptor);
+ ExFreePool(descriptor);
+}
\ No newline at end of file
diff --git a/include/ddk/fltkernel.h b/include/ddk/fltkernel.h
index 49c9d55dbaa..e5483d5a3fa 100644
--- a/include/ddk/fltkernel.h
@ -150,5 +149,5 @@ index 49c9d55dbaa..e5483d5a3fa 100644
NTSTATUS WINAPI FltRegisterFilter(PDRIVER_OBJECT, const FLT_REGISTRATION *, PFLT_FILTER *);
NTSTATUS WINAPI FltStartFiltering(PFLT_FILTER);
--
2.40.1
2.42.0

View File

@ -1,4 +1,4 @@
From 9cb5114cbf5af7c360ffb653fc286b8bf9e21db3 Mon Sep 17 00:00:00 2001
From c1af142bac149b296b2dea06cd99c13e0f8814c9 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 30 Aug 2021 15:15:35 +1000
Subject: [PATCH 2/3] fltmgr.sys: Create import library
@ -9,7 +9,7 @@ Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
1 file changed, 1 insertion(+)
diff --git a/dlls/fltmgr.sys/Makefile.in b/dlls/fltmgr.sys/Makefile.in
index bb1f34b4896..5540df35d6a 100644
index ae0e812cb22..ae02da9b5d6 100644
--- a/dlls/fltmgr.sys/Makefile.in
+++ b/dlls/fltmgr.sys/Makefile.in
@@ -1,4 +1,5 @@
@ -19,5 +19,5 @@ index bb1f34b4896..5540df35d6a 100644
IMPORTS = ntoskrnl
--
2.40.1
2.42.0

View File

@ -1,4 +1,4 @@
From 8d12d4dac0cbc7194d11e398b4d3371bef8a1952 Mon Sep 17 00:00:00 2001
From c69247afcbd83af223f471342c67bc06deeffda0 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 30 Aug 2021 15:16:06 +1000
Subject: [PATCH] ntoskrnl.exe: Add FltBuildDefaultSecurityDescriptor test
@ -6,11 +6,11 @@ Subject: [PATCH] ntoskrnl.exe: Add FltBuildDefaultSecurityDescriptor test
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/ntoskrnl.exe/tests/Makefile.in | 2 +-
dlls/ntoskrnl.exe/tests/driver.c | 65 +++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 1 deletion(-)
dlls/ntoskrnl.exe/tests/driver.c | 81 +++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/tests/Makefile.in b/dlls/ntoskrnl.exe/tests/Makefile.in
index ab1db85adbb..9c89e44e70a 100644
index f610df6a947..97dee8b25cf 100644
--- a/dlls/ntoskrnl.exe/tests/Makefile.in
+++ b/dlls/ntoskrnl.exe/tests/Makefile.in
@@ -1,7 +1,7 @@
@ -23,10 +23,10 @@ index ab1db85adbb..9c89e44e70a 100644
driver2_IMPORTS = winecrt0 ntoskrnl hal
driver2_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index c8797e8d8e0..168b47941e8 100644
index ea4bd03ee44..844a181472c 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -32,6 +32,7 @@
@@ -36,6 +36,7 @@
#include "ddk/ntddk.h"
#include "ddk/ntifs.h"
#include "ddk/wdm.h"
@ -34,7 +34,7 @@ index c8797e8d8e0..168b47941e8 100644
#include "driver.h"
@@ -2372,6 +2373,69 @@ static void test_default_modules(void)
@@ -2393,6 +2394,85 @@ static void test_default_modules(void)
ok(dxgmms1, "Failed to find dxgmms1.sys\n");
}
@ -47,10 +47,17 @@ index c8797e8d8e0..168b47941e8 100644
+ PACL acl = NULL;
+ PACCESS_ALLOWED_ACE ace;
+ SID_IDENTIFIER_AUTHORITY auth = { SECURITY_NULL_SID_AUTHORITY };
+ PSID sid1, sid2;
+ SID_IDENTIFIER_AUTHORITY authwine7 = { SECURITY_NT_AUTHORITY };
+ PSID sid1, sid2, sidwin7;
+ BOOL ret;
+
+ status = FltBuildDefaultSecurityDescriptor(&sd, STANDARD_RIGHTS_ALL);
+ ok(status == STATUS_SUCCESS, "got %#lx\n", status);
+ if (status != STATUS_SUCCESS)
+ {
+ win_skip("Skipping FltBuildDefaultSecurityDescriptor tests\n");
+ return;
+ }
+ ok(sd != NULL, "Failed to return descriptor\n");
+
+ status = RtlGetGroupSecurityDescriptor(sd, &group, &isdefault);
@ -67,10 +74,17 @@ index c8797e8d8e0..168b47941e8 100644
+ ok(acl->AceCount == 2, "got %d\n", acl->AceCount);
+
+ sid1 = ExAllocatePool(NonPagedPool, RtlLengthRequiredSid(2));
+ RtlInitializeSid(sid1, &auth, 2);
+ status = RtlInitializeSid(sid1, &auth, 2);
+ ok(status == STATUS_SUCCESS, "got %#lx\n", status);
+ *RtlSubAuthoritySid(sid1, 0) = SECURITY_BUILTIN_DOMAIN_RID;
+ *RtlSubAuthoritySid(sid1, 1) = DOMAIN_GROUP_RID_ADMINS;
+
+ sidwin7 = ExAllocatePool(NonPagedPool, RtlLengthRequiredSid(2));
+ status = RtlInitializeSid(sidwin7, &authwine7, 2);
+ ok(status == STATUS_SUCCESS, "got %#lx\n", status);
+ *RtlSubAuthoritySid(sidwin7, 0) = SECURITY_BUILTIN_DOMAIN_RID;
+ *RtlSubAuthoritySid(sidwin7, 1) = DOMAIN_ALIAS_RID_ADMINS;
+
+ sid2 = ExAllocatePool(NonPagedPool, RtlLengthRequiredSid(1));
+ RtlInitializeSid(sid2, &auth, 1);
+ *RtlSubAuthoritySid(sid2, 0) = SECURITY_LOCAL_SYSTEM_RID;
@ -83,7 +97,8 @@ index c8797e8d8e0..168b47941e8 100644
+ ok(ace->Header.AceFlags == 0, "got %#x\n", ace->Header.AceFlags);
+ ok(ace->Mask == STANDARD_RIGHTS_ALL, "got %#lx\n", ace->Mask);
+
+ ok(RtlEqualSid(sid1, (PSID)&ace->SidStart), "SID not equal\n");
+ ret = RtlEqualSid(sid1, (PSID)&ace->SidStart) || RtlEqualSid(sidwin7, (PSID)&ace->SidStart);
+ ok(ret, "SID not equal\n");
+
+ /* SECURITY_LOCAL_SYSTEM_RID */
+ status = RtlGetAce(acl, 1, (void**)&ace);
@ -93,7 +108,8 @@ index c8797e8d8e0..168b47941e8 100644
+ ok(ace->Header.AceFlags == 0, "got %#x\n", ace->Header.AceFlags);
+ ok(ace->Mask == STANDARD_RIGHTS_ALL, "got %#lx\n", ace->Mask);
+
+ ok(RtlEqualSid(sid2, (PSID)&ace->SidStart), "SID not equal\n");
+ ret = RtlEqualSid(sid2, (PSID)&ace->SidStart) || RtlEqualSid(sidwin7, (PSID)&ace->SidStart);
+ ok(ret, "SID not equal\n");
+
+ ExFreePool(sid1);
+ ExFreePool(sid2);
@ -104,7 +120,7 @@ index c8797e8d8e0..168b47941e8 100644
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack)
{
void *buffer = irp->AssociatedIrp.SystemBuffer;
@@ -2417,6 +2481,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
@@ -2438,6 +2518,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
test_process_memory(test_input);
test_permanence();
test_driver_object_extension();
@ -113,5 +129,5 @@ index c8797e8d8e0..168b47941e8 100644
IoMarkIrpPending(irp);
IoQueueWorkItem(work_item, main_test_task, DelayedWorkQueue, irp);
--
2.40.1
2.42.0