reactos/ntoskrnl/ob
George Bișoc 00c69bcd15
[NTOS:OB] Properly calculate the return length in ObQueryTypeInfo
On a x86 system aligning the return length pointer to a 4-byte boundary
works best since pointers in general are 4-byte aligned for x86 systems.

However, what happens on a AMD64 system is that we still align this pointer
to 4-byte, ObjectTypeInfo is a 8-byte pointer and we might write into
the return length past the 4-byte boundary.

If one were to allocate a pool of memory with that length and query all
the object types info and free the said pool of memory thereafter, the
system will crash with BAD_POOL_HEADER because ObQueryTypeInfo overwrote
the return length past the 4-byte boundary length therefore leading up with
corrupted memory blocks in the pool header.

This symptom of BAD_POOL_HEADER happens exactly the same in Windows Server
2003 x64 Edition. Newer versions of Windows like 10 aren't affected.

But, Windows has another bug where they are using MaximumLength for the
calculation of the needed length to be returned to caller. MaximumLength
does not guarantee you that it includes the NULL-terminator in the length
and that potentially leads to a buffer overrun.

Also annotate the ObQueryTypeInfo function with SAL2.

https://processhacker.sourceforge.io/doc/object_8c_source.html (read the
comment in KphObjectTypeInformation).
2023-04-21 12:45:31 +02:00
..
devicemap.c [NTOS:OB] ObQueryDeviceMapInformation(): Fix annotations 2021-05-01 11:26:07 +02:00
obdir.c [NTOS:OB] Minor refactoring. 2021-09-25 01:09:01 +02:00
obhandle.c [NTOS:OB] Include the security descriptor charge when charging the paged pool quota of an object 2022-06-26 19:47:02 +02:00
obinit.c [NTOS:OB] Clarify and fix the usage of the Obp*DirectoryLock*() and ObpReleaseLookupContextObject() functions. 2021-09-25 00:47:43 +02:00
oblife.c [NTOS:OB] Properly calculate the return length in ObQueryTypeInfo 2023-04-21 12:45:31 +02:00
oblink.c [NTOS:OB] Minor refactoring. 2021-09-25 01:09:01 +02:00
obname.c [NTOS] Add TAG_DACL in tag.h and use it. 2022-11-03 02:55:49 +01:00
obref.c [NTOS:OB] Do not close the handle if it's granted access to ObpAccessProtectCloseBit 2021-04-26 19:36:38 +02:00
obsdcach.c [FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
obsecure.c [NTOS:OB] Specify the query security descriptor tag when freeing the allocation 2022-05-08 19:16:34 +02:00
obwait.c [FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00