Skip to content

Conversation

@Javagedes
Copy link
Contributor

@Javagedes Javagedes commented Dec 17, 2025

Description

This commit stops the library for querying the protocol database for the
status code protocol at the time of use of the library function. This
logic can result in a TPL inversion if the protocol has not yet been
located and the caller is running in a TPL higher then TPL_NOTIFY.

Instead, the protocol is now located during construction of the library
during driver startup. If the protocol is not found, then an on-protocol
install event is registered. A deconstructor is also added to close the
event in the case that the driver is unloaded before the protocol is
installed.

This PR is a rebase and fast forward as it includes a new test.

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

  1. The written unit test, which failed in the first commit, now passes after the second commit
  2. Verified that the event callback is successfully executed in all drivers that run before the protocol is produced, including the DXE Core.
  3. Verified the steps to reproduce specified in [Bug]: Potential TPL inversion in ReportStatusCodeLib (DXE and Runtime) #1601 no longer reproduces.

Integration Instructions

N/A

@Javagedes Javagedes self-assigned this Dec 17, 2025
@Javagedes Javagedes added the type:bug Something isn't working label Dec 17, 2025
@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch from afb96fb to dbb5edc Compare December 17, 2025 18:29
@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch 3 times, most recently from ed956ed to 89ea636 Compare December 17, 2025 18:58
@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 0% with 115 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/202502@1009044). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...untimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 0.00% 68 Missing ⚠️
...tStatusCodeLib/TestDxeReportStatusCodeLibTestApp.c 0.00% 45 Missing ⚠️
...brary/DxeReportStatusCodeLib/ReportStatusCodeLib.c 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             release/202502    #1602   +/-   ##
=================================================
  Coverage                  ?    1.32%           
=================================================
  Files                     ?      802           
  Lines                     ?   306180           
  Branches                  ?     2120           
=================================================
  Hits                      ?     4051           
  Misses                    ?   302109           
  Partials                  ?       20           
Flag Coverage Δ
MdeModulePkg 1.55% <0.00%> (?)
NetworkPkg 0.55% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@os-d os-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you take this to edk2, too?

@Javagedes
Copy link
Contributor Author

Can you take this to edk2, too?

ya, I will. Figured we wanted this here first though

@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch from 89ea636 to 3c7de8c Compare December 17, 2025 22:17
@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch 2 times, most recently from b938184 to 27ce6c2 Compare December 18, 2025 16:41
@Javagedes
Copy link
Contributor Author

I have re-requested all reviews, as I have made a fundamental change to the pull request.

@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch from 27ce6c2 to e7f73d1 Compare December 18, 2025 16:44
@Javagedes Javagedes linked an issue Dec 18, 2025 that may be closed by this pull request
1 task
@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch 3 times, most recently from fbd8e25 to 4994b4c Compare December 18, 2025 21:42
@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch 4 times, most recently from 95f48c7 to ccc6b80 Compare December 18, 2025 21:52
@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch 4 times, most recently from 663f9ac to 75c5980 Compare December 18, 2025 23:05
@Javagedes Javagedes enabled auto-merge (rebase) December 18, 2025 23:05
This commit adds a UEFI_APPLICATION unit test for DxeReportStatusCodeLib
that ensures that the platform does not invert the TPL on an initial
call to ReportStatusCode functionality.

This functionality has the potential to invert the TPL due to the fact
that on an initial call to report status code functionality, if the
EFI_STATUS_CODE protocal has not been located, it will attempt to locate
it. LocateProtocol performs a tpl raise to EFI_NOTIFY. If the caller of
ReportStatusCode is in a TPL higher then EFI_NOTIFY, we will invert the
TPL and assert.
This commit stops the library for querying the protocol database for the
status code protocol at the time of use of the library function. This
logic can result in a TPL inversion if the protocol has not yet been
located and the caller is running in a TPL higher then TPL_NOTIFY.

Instead, the protocol is now located during construction of the library
during driver startup. If the protocol is not found, then an on-protocol
install event is registered. A deconstructor is also added to close the
event in the case that the driver is unloaded before the protocol is
installed.
This commit stops the library for querying the protocol database for the
status code protocol at the time of use of the library function. This
logic can result in a TPL inversion if the protocol has not yet been
located and the caller is running in a TPL higher then TPL_NOTIFY.

Instead, the protocol is now located during construction of the library
during driver startup. If the protocol is not found, then an on-protocol
install event is registered. A deconstructor is also added to close the
event in the case that the driver is unloaded before the protocol is
installed.
@Javagedes Javagedes force-pushed the personal/joeyvagedes/report-status-code-lib-test branch from 75c5980 to 4ebfdfd Compare December 23, 2025 16:42
@Javagedes Javagedes merged commit 557324c into microsoft:release/202502 Dec 23, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Potential TPL inversion in ReportStatusCodeLib (DXE and Runtime)

6 participants