Skip to content

ShellPkg/UefiHandleParsingLib: support handle list growth#12289

Merged
mergify[bot] merged 2 commits intotianocore:masterfrom
bobm21:HandleParsingLib
Mar 26, 2026
Merged

ShellPkg/UefiHandleParsingLib: support handle list growth#12289
mergify[bot] merged 2 commits intotianocore:masterfrom
bobm21:HandleParsingLib

Conversation

@bobm21
Copy link
Copy Markdown
Contributor

@bobm21 bobm21 commented Mar 13, 2026

Refactor GetHandleListByProtocol() to support additions to the handle list during its execution. Replace LocateHandle() with LocateHandleBuffer() to avoid the possibility that the buffer allocated for LocateHandle() is too small if additional handles
are added during GetHandleListByProtocol() execution.

Note that the previous implementation did not detect the handle list growth and would cause memory
corruption when writing the terminating NULL handle to the allocated buffer.

Description

Fixes an intermittent problem where the second LocateHandle call in the EFI_BUFFER_TOO_SMALL handling also failed with EFI_BUFFER_TOO_SMALL due to a handle being added between the two LocateHandle calls, but since Status of the second call is not checked, the writing of the NULL terminating entry using the new Size value in HandleList[Size/sizeof (EFI_HANDLE)] corrupted the allocated buffer trailer causing an ASSERT when the HandleList was freed.

  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

Re-ran the repetitive test that had been hitting the intermittent failure.

Integration Instructions

N/A

Comment thread ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c Outdated
@bobm21 bobm21 force-pushed the HandleParsingLib branch 2 times, most recently from 5e0e69d to ceb1eb3 Compare March 14, 2026 04:02
Comment thread ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c Outdated
Comment thread ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
Comment thread ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c Outdated
Comment thread ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c Outdated
@bobm21 bobm21 force-pushed the HandleParsingLib branch 2 times, most recently from bdba2df to 55bcb31 Compare March 15, 2026 17:52
Comment thread ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c Outdated
@bobm21 bobm21 force-pushed the HandleParsingLib branch from 55bcb31 to da29522 Compare March 16, 2026 17:12
@bobm21 bobm21 force-pushed the HandleParsingLib branch 3 times, most recently from e40e4f2 to ce4408c Compare March 25, 2026 15:39
Refactor GetHandleListByProtocol() to support
additions to the handle list during its execution.
Replace LocateHandle() with LocateHandleBuffer() to
avoid the possibility that the buffer allocated for
LocateHandle() is too small if additional handles
are added during GetHandleListByProtocol() execution.

Note that the previous implementation did not detect
the handle list growth and would cause memory
corruption when writing the terminating NULL handle
to the allocated buffer.

Signed-off-by: Bob Morgan <bobm@nvidia.com>
@bobm21 bobm21 force-pushed the HandleParsingLib branch from ce4408c to 3658134 Compare March 26, 2026 01:20
@mdkinney
Copy link
Copy Markdown
Member

@bobm21 Why forced push changes after review?

@bobm21
Copy link
Copy Markdown
Contributor Author

bobm21 commented Mar 26, 2026

@bobm21 Why forced push changes after review?

Sorry, wasn't sure if I needed to rebase on tip.

@mdkinney
Copy link
Copy Markdown
Member

@bobm21 Why forced push changes after review?

Sorry, wasn't sure if I needed to rebase on tip.

Mergify handles that automatically when push label is set.

@mdkinney mdkinney added the push Auto push patch series in PR if all checks pass label Mar 26, 2026
@mergify mergify Bot added the queued label Mar 26, 2026
@mergify
Copy link
Copy Markdown

mergify Bot commented Mar 26, 2026

Merge Queue Status

  • Entered queue2026-03-26 16:17 UTC · Rule: default
  • Checks passed · in-place
  • Merged2026-03-26 17:36 UTC · at 5bb7371be64b0f7caeb6c6df7212b37d25787c6a

This pull request spent 1 hour 19 minutes 25 seconds in the queue, including 28 minutes 35 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = tianocore.PatchCheck
    • check-neutral = tianocore.PatchCheck
    • check-skipped = tianocore.PatchCheck
  • any of [🛡 GitHub branch protection]:
    • check-success = ArmVirtPkg - Ubuntu GCC - PR
    • check-neutral = ArmVirtPkg - Ubuntu GCC - PR
    • check-skipped = ArmVirtPkg - Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = EmulatorPkg - Ubuntu GCC - PR
    • check-neutral = EmulatorPkg - Ubuntu GCC - PR
    • check-skipped = EmulatorPkg - Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = EmulatorPkg - Windows VS - PR
    • check-neutral = EmulatorPkg - Windows VS - PR
    • check-skipped = EmulatorPkg - Windows VS - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = OvmfPkg - Ubuntu GCC - PR
    • check-neutral = OvmfPkg - Ubuntu GCC - PR
    • check-skipped = OvmfPkg - Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = OvmfPkg - Windows VS - PR
    • check-neutral = OvmfPkg - Windows VS - PR
    • check-skipped = OvmfPkg - Windows VS - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = Windows VS - PR
    • check-neutral = Windows VS - PR
    • check-skipped = Windows VS - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = Ubuntu GCC - PR
    • check-neutral = Ubuntu GCC - PR
    • check-skipped = Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = Validate Pull Request Formatting
    • check-neutral = Validate Pull Request Formatting
    • check-skipped = Validate Pull Request Formatting
  • any of [🛡 GitHub branch protection]:
    • check-success = ArmVirtPkg - Ubuntu - CLANGPDB
    • check-neutral = ArmVirtPkg - Ubuntu - CLANGPDB
    • check-skipped = ArmVirtPkg - Ubuntu - CLANGPDB
  • any of [🛡 GitHub branch protection]:
    • check-success = OvmfPkg - Ubuntu - CLANGPDB
    • check-neutral = OvmfPkg - Ubuntu - CLANGPDB
    • check-skipped = OvmfPkg - Ubuntu - CLANGPDB
  • any of [🛡 GitHub branch protection]:
    • check-success = Ubuntu - CLANGPDB
    • check-neutral = Ubuntu - CLANGPDB
    • check-skipped = Ubuntu - CLANGPDB

@mergify mergify Bot merged commit c4d29cb into tianocore:master Mar 26, 2026
140 of 141 checks passed
@mergify mergify Bot removed the queued label Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

push Auto push patch series in PR if all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants