Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 5bc52de6877a1e70adc91e3242394044155518bb
      
https://github.com/tianocore/edk2/commit/5bc52de6877a1e70adc91e3242394044155518bb
  Author: Oliver Smith-Denny <o...@microsoft.com>
  Date:   2025-05-07 (Wed, 07 May 2025)

  Changed paths:
    M MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c

  Log Message:
  -----------
  MdeModulePkg: DebugImageInfoTable: Fix Array Maintenance

The DebugImageInfoTable contains an array of image info
structures. The current implementation removes an entry by
freeing the info structure and putting NULL in that entry of
the array. It then decrements the table size tracked in the table.
However, the array is invalid at this point, it contains a NULL
entry, which the UEFI spec does not envision and it contains a valid
entry past the end of the array as tracked in the spec defined config
table. If the table is consumed at this point it can lead to an
invalid assessment of the image state, which defeats the purpose of
the table.

When a new info structure is added, it then scans for the first NULL
entry adds a pointer to the new info structure there and increments
the table size to cover the entrythat was formerly past the end of
the array.

The current implementation requires that once an unload happens,
more loads happen than unloads and that the last operation is not
an unload (which won't be true in the shell, e.g.). This is
needlessly complex, as the order of the table doesn't matter
(and in fact this implementation doesn't preserve image loading
order either).

This patch updates the removal function to free the desired
info structure, move the last entry of the array to this freed
spot, mark the last entry as NULL, and decrement the table count.
The entry addition function then just always puts a new entry at
the end of the array, expanding it as necessary. This simplifies
the logic and covers the gaps that were present.

Signed-off-by: Oliver Smith-Denny <o...@microsoft.com>



To unsubscribe from these emails, change your notification settings at 
https://github.com/tianocore/edk2/settings/notifications


_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to