Repository navigation
[CHERRY-PICK] Stop USB enumeration in case a malformed descriptor is found (#410) - #412
Merged
Oliver Smith-Denny (os-d) merged 1 commit intoMay 23, 2023
Conversation
…ft#410) ## Description When parsing interface descriptors for an attached USB device, the USB bus driver correctly handles cases where a device has a malformed interface . `UsbParseInterfaceDesc` returns `NULL` in such cases. `UsbParseConfigDesc` which parses interface descriptors, stops parsing in case `UsbParseInterfaceDesc` returns NULL but still returns `EFI_SUCCESS` along with a partially filled `USB_CONFIG_DESC` structure. This causes access exceptions when attempts are made subsequently to communicate with the downstream device (for e.g. during endpoint configuration) as the driver does not have valid interface descriptor structures associated with the device. To fix this, `UsbParseConfigDesc` should take the error path in cases where `UsbParseInterfaceDesc` returns NULL and abandon enumerating the device. This will allow a platform to boot instead of crashing when a buggy USB device is attached to it. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested Tested on a platform with a USB keyboard that returns a malformed USB interface descriptor. The platform fails to boot with an access violation exception without this fix. ## Integration Instructions Updating to the latest MU_BASECORE will automatically include this fix if the UsbBus DXE driver is included in the fdf/dscs.
Oliver Smith-Denny (os-d)
requested review from
kuqin12 and
Michael Kubacki (makubacki)
May 23, 2023 20:49
kuqin12
approved these changes
May 23, 2023
Michael Kubacki (makubacki)
approved these changes
May 23, 2023
Project Mu Bot [bot] (ProjectMuBot)
referenced
this pull request
in microsoft/mu_tiano_platforms
May 24, 2023
Introduces 10 new commits in [MU_BASECORE](https://github.com/microsoft/mu_basecore.git). <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/microsoft/mu_basecore/commit/a296f04604fd32db6d862646f3dd25ba2d5514e2">a296f0</a> Introduce Standalone MM Policy Service (<a href="https://github.com/microsoft/mu_basecore/pull/390">#390</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/d4d7856f93bdcfdb785a81aa3830d8e871f6b113">d4d785</a> Add basic wrappers to the Policy Library (<a href="https://github.com/microsoft/mu_basecore/pull/396">#396</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/68f1e801de4c8f1ab970ffb331eb8d4efd69ab9b">68f1e8</a> pip: update edk2-pytool-extensions requirement from ~=0.23.0 to ~=0.23.2 (<a href="https://github.com/microsoft/mu_basecore/pull/397">#397</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/346e17b532854248bf6378b70075142e4751bff8">346e17</a> pip: bump edk2-basetools from 0.1.45 to 0.1.48 (<a href="https://github.com/microsoft/mu_basecore/pull/401">#401</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/19a366b2b3272bc6031fbab65ad1326085f2303c">19a366</a> Create Github Workflow to publish basetools on release (<a href="https://github.com/microsoft/mu_basecore/pull/385">#385</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/656456cd5fcd0f104e9a8813b953b1ab7492cc71">656456</a> Additional CodeQL Fixes (<a href="https://github.com/microsoft/mu_basecore/pull/400">#400</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/01a4ed58fbb9c284fa254ec5b04be4febd8a0c9d">01a4ed</a> pip: update edk2-pytool-library requirement from ~=0.14.1 to ~=0.15.0 (<a href="https://github.com/microsoft/mu_basecore/pull/405">#405</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/f421222215ad57feed9bd29a38ff61e13adcf2df">f42122</a> pip: bump antlr4-python3-runtime from 4.12.0 to 4.13.0 (<a href="https://github.com/microsoft/mu_basecore/pull/408">#408</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/c03dc558c048af7863b7d7e30fbf2e34b5b53c51">c03dc5</a> pip: update edk2-pytool-extensions requirement from ~=0.23.2 to ~=0.23.3 (<a href="https://github.com/microsoft/mu_basecore/pull/406">#406</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/3179184b360bb7ad2dc979f45cddb242d6b995c3">317918</a> [CHERRY-PICK] Stop USB enumeration in case a malformed descriptor is found (<a href="https://github.com/microsoft/mu_basecore/pull/410">#410</a>) (<a href="https://github.com/microsoft/mu_basecore/pull/412">#412</a>)</li> </ul> </details> Signed-off-by: Project Mu Bot <mubot@microsoft.com>
Michael Kubacki (makubacki)
referenced
this pull request
in microsoft/mu_tiano_platforms
May 24, 2023
Bumps MU_BASECORE from `2022080002.0.1` to `2022080002.0.2` Introduces 10 new commits in [MU_BASECORE](https://github.com/microsoft/mu_basecore.git). <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/microsoft/mu_basecore/commit/a296f04604fd32db6d862646f3dd25ba2d5514e2">a296f0</a> Introduce Standalone MM Policy Service (<a href="https://github.com/microsoft/mu_basecore/pull/390">#390</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/d4d7856f93bdcfdb785a81aa3830d8e871f6b113">d4d785</a> Add basic wrappers to the Policy Library (<a href="https://github.com/microsoft/mu_basecore/pull/396">#396</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/68f1e801de4c8f1ab970ffb331eb8d4efd69ab9b">68f1e8</a> pip: update edk2-pytool-extensions requirement from ~=0.23.0 to ~=0.23.2 (<a href="https://github.com/microsoft/mu_basecore/pull/397">#397</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/346e17b532854248bf6378b70075142e4751bff8">346e17</a> pip: bump edk2-basetools from 0.1.45 to 0.1.48 (<a href="https://github.com/microsoft/mu_basecore/pull/401">#401</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/19a366b2b3272bc6031fbab65ad1326085f2303c">19a366</a> Create Github Workflow to publish basetools on release (<a href="https://github.com/microsoft/mu_basecore/pull/385">#385</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/656456cd5fcd0f104e9a8813b953b1ab7492cc71">656456</a> Additional CodeQL Fixes (<a href="https://github.com/microsoft/mu_basecore/pull/400">#400</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/01a4ed58fbb9c284fa254ec5b04be4febd8a0c9d">01a4ed</a> pip: update edk2-pytool-library requirement from ~=0.14.1 to ~=0.15.0 (<a href="https://github.com/microsoft/mu_basecore/pull/405">#405</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/f421222215ad57feed9bd29a38ff61e13adcf2df">f42122</a> pip: bump antlr4-python3-runtime from 4.12.0 to 4.13.0 (<a href="https://github.com/microsoft/mu_basecore/pull/408">#408</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/c03dc558c048af7863b7d7e30fbf2e34b5b53c51">c03dc5</a> pip: update edk2-pytool-extensions requirement from ~=0.23.2 to ~=0.23.3 (<a href="https://github.com/microsoft/mu_basecore/pull/406">#406</a>)</li> <li><a href="https://github.com/microsoft/mu_basecore/commit/3179184b360bb7ad2dc979f45cddb242d6b995c3">317918</a> [CHERRY-PICK] Stop USB enumeration in case a malformed descriptor is found (<a href="https://github.com/microsoft/mu_basecore/pull/410">#410</a>) (<a href="https://github.com/microsoft/mu_basecore/pull/412">#412</a>)</li> </ul> </details> Signed-off-by: Project Mu Bot <mubot@microsoft.com>
Kat Perez (kat-perez)
pushed a commit
to kat-perez/mu_basecore
that referenced
this pull request
Nov 9, 2025
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a cherry-pick of commit 714d41b to release/202208.
When parsing interface descriptors for an attached USB device, the USB bus driver correctly handles cases where a device has a malformed interface .
UsbParseInterfaceDescreturnsNULLin such cases.UsbParseConfigDescwhich parses interface descriptors, stops parsing in caseUsbParseInterfaceDescreturns NULL but still returnsEFI_SUCCESSalong with a partially filledUSB_CONFIG_DESCstructure.This causes access exceptions when attempts are made subsequently to communicate with the downstream device (for e.g. during endpoint configuration) as the driver does not have valid interface descriptor structures associated with the device.
To fix this,
UsbParseConfigDescshould take the error path in cases whereUsbParseInterfaceDescreturns NULL and abandon enumerating the device. This will allow a platform to boot instead of crashing when a buggy USB device is attached to it.How This Was Tested
Tested on a platform with a USB keyboard that returns a malformed USB interface descriptor. The platform fails to boot with an access violation exception without this fix.
Integration Instructions
Updating to the latest MU_BASECORE will automatically include this fix if the UsbBus DXE driver is included in the fdf/dscs.
Preface
Please ensure you have read the contribution docs prior
to submitting the pull request. In particular,
pull request guidelines.
Description
<Please include a description of the change and why this change was made.>
For each item, place an "x" in between
[and]if true. Example:[x].(you can also check items in the GitHub UI)
flow, or firmware?
validation improvement, ...
in build or boot behavior?
a function in a new library class in a pre-existing module, ...
outside direct code modifications (and comments)?
on an a separate Web page, ...
How This Was Tested
<Please describe the test(s) that were run to verify the changes.>
Integration Instructions
<Describe how these changes should be integrated. Use N/A if nothing is required.>