[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.
This commit is contained in:
George Bișoc 2021-12-30 21:04:42 +01:00
parent ee697cfeef
commit 0c07eac5b4
No known key found for this signature in database
GPG key ID: 688C4FBE25D7DEF6
2 changed files with 19 additions and 15 deletions

View file

@ -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;

View file

@ -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);
}
}
}