public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Is CoreValidateHandle() safe?
@ 2021-01-12  0:03 Andrew Fish
  2021-01-12  1:51 ` [edk2-devel] " Michael D Kinney
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Fish @ 2021-01-12  0:03 UTC (permalink / raw)
  To: edk2-devel-groups-io

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

I just hit the CR ASSERT [1] in CoreValidateHandle(). It looks like the IHANDLE was a use after free as it was a Pool buffer that was to small to be an IHANDLE and it did not have a valid handle. 

I’m trying to understand why it is safe to walk the gHandleList without a lock? Seems like a local could cache a pointer and an event could remove a handle and Link would point to a stale handle?

Kind of feels like I’m missing something?

[1] https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Hand/Handle.c#L64
EFI_STATUS
CoreValidateHandle (
  IN  EFI_HANDLE                UserHandle
  )
{
  IHANDLE             *Handle;
  LIST_ENTRY          *Link;

  if (UserHandle == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  for (Link = gHandleList.BackLink; Link != &gHandleList; Link = Link->BackLink) {
    Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
    if (Handle == (IHANDLE *) UserHandle) {
      return EFI_SUCCESS;
    }
  }

  return EFI_INVALID_PARAMETER;
}

Thanks,

Andrew Fish

[-- Attachment #2: Type: text/html, Size: 22243 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-14  3:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-12  0:03 Is CoreValidateHandle() safe? Andrew Fish
2021-01-12  1:51 ` [edk2-devel] " Michael D Kinney
2021-01-12  7:08   ` Andrew Fish
     [not found]   ` <16596A642FC06686.22089@groups.io>
2021-01-14  3:56     ` Andrew Fish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox