https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0c07eac5b40b05df5153a…
commit 0c07eac5b40b05df5153ac5d44d85e1952e09645
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Thu Dec 30 21:04:42 2021 +0100
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Tue Jan 11 10:11:10 2022 +0100
[NTOS:OB] Charge/Return pool quotas of objects
As it currently stands the Object Manager doesn't charge any quotas when objects
are created, nor it returns quotas when objects are de-allocated and freed from the
objects namespace database. This alone can bring inconsistencies in the kernel as we
simply don't know what is the amount charged in an object and thus we aren't
keeping track of quotas flow.
Now with both PsReturnSharedPoolQuota and PsChargeSharedPoolQuota implemented, the
Object Manager can now track the said flow of quotas every time an object is created or
de-allocated, thus enforcing consistency with the use of quota resources.
---
ntoskrnl/ob/obhandle.c | 21 +++++++++++++--------
ntoskrnl/ob/oblife.c | 13 ++++++-------
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/ntoskrnl/ob/obhandle.c b/ntoskrnl/ob/obhandle.c
index cff2cbb80e9..bf9f1f09cb5 100644
--- a/ntoskrnl/ob/obhandle.c
+++ b/ntoskrnl/ob/obhandle.c
@@ -457,14 +457,19 @@ ObpChargeQuotaForObject(IN POBJECT_HEADER ObjectHeader,
NonPagedPoolCharge = ObjectType->TypeInfo.DefaultNonPagedPoolCharge;
}
- /* Charge the quota */
- ObjectHeader->QuotaBlockCharged = (PVOID)1;
- DPRINT("FIXME: Should charge: %lx %lx\n", PagedPoolCharge,
NonPagedPoolCharge);
-#if 0
- PsChargeSharedPoolQuota(PsGetCurrentProcess(),
- PagedPoolCharge,
- NonPagedPoolCharge);
-#endif
+ /* Is this the system process? */
+ if (PsGetCurrentProcess() == PsInitialSystemProcess)
+ {
+ /* It is, don't do anything */
+ ObjectHeader->QuotaBlockCharged = OBP_SYSTEM_PROCESS_QUOTA;
+ }
+ else
+ {
+ /* Charge the quota */
+ ObjectHeader->QuotaBlockCharged =
PsChargeSharedPoolQuota(PsGetCurrentProcess(),
+ PagedPoolCharge,
+
NonPagedPoolCharge);
+ }
/* Check if we don't have a quota block */
if (!ObjectHeader->QuotaBlockCharged) return STATUS_QUOTA_EXCEEDED;
diff --git a/ntoskrnl/ob/oblife.c b/ntoskrnl/ob/oblife.c
index 06c0d96e904..f46cb4098b3 100644
--- a/ntoskrnl/ob/oblife.c
+++ b/ntoskrnl/ob/oblife.c
@@ -110,13 +110,12 @@ ObpDeallocateObject(IN PVOID Object)
}
/* Return the quota */
- DPRINT("FIXME: Should return quotas: %lx %lx\n", PagedPoolCharge,
NonPagedPoolCharge);
-#if 0
- PsReturnSharedPoolQuota(ObjectHeader->QuotaBlockCharged,
- PagedPoolCharge,
- NonPagedPoolCharge);
-#endif
-
+ if (Header->QuotaBlockCharged != OBP_SYSTEM_PROCESS_QUOTA)
+ {
+ PsReturnSharedPoolQuota(Header->QuotaBlockCharged,
+ PagedPoolCharge,
+ NonPagedPoolCharge);
+ }
}
}