Patina: Fix RAW FFS file handling and harden section parsing#1369
Conversation
ℹ️ QEMU Validation Skipped - PR MergedThe Patina QEMU PR validation workflow did not run because the PR was merged before validation started. Workflow run: https://github.com/OpenDevicePartnership/patina/actions/runs/22963784661
This comment was automatically generated by the Patina QEMU PR Validation Post workflow. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
2d91fd6 to
8d5ac18
Compare
|
Please hold on this PR, Got the fv from IDC folks, It looks like there is more to the actual bug. I will notify once I finished root causing the issue. |
67de51a to
6441216
Compare
6441216 to
46743be
Compare
46743be to
9e9e9ee
Compare
|
@vineelko, the PR title gives the impression this is a broad FFS section parsing issue and I think it really comes down to RAW files and some other cleanup. If that's the case, could you consider updating the title? |
|
Fixed the title Michael. |
Improve safety in FFS section parsing by replacing direct slice indexing with bounds checked `get()` calls and proper error propagation when buffers are malformed. Add handling for SectionType::ALL to treat the entire section buffer as raw data per UEFI C implementation. Update DXEFV.fv test files. Fixes the following bug: ``` [ INFO]: \patina\sdk\patina\src\pi\serializable\serializable_fv.rs@078: Parsing FV: d2c29ba7-3809-480f-9c3d-de389c61425a [ INFO]: \patina\sdk\patina\src\pi\serializable\serializable_fv.rs@089: Parsing file: 197db236-f856-4924-90f8-cdf12fb875f3 [ INFO]: \patina\sdk\patina\src\pi\fw_fs.rs@801: Section type 0x0 unrecognized 4 1, treating as opaque with no metadata [ERROR]: dxe_readiness_capture\src\lib.rs@031: panicked at \patina\sdk\patina\src\pi\fw_fs.rs:805:56: [ERROR]: dxe_readiness_capture\src\lib.rs@031: slice index starts at 4 but ends at 1 ``` Signed-off-by: Vineel Kovvuri[MSFT] <vineelko@microsoft.com>
- Only a few structs could be marked as ZeroCopy compatible. Structs containing r-efi::Guid fields cannot implement ZeroCopy because the r-efi types do not implement the required traits. Signed-off-by: Vineel Kovvuri[MSFT] <vineelko@microsoft.com>
- The current implementation tries to produce sections irrespective of the file
type. This do not hold true for RAW file types. As per PI spec below,
The file type EFI_FV_FILETYPE_RAW denotes a file that does not contain
sections and is treated as a raw data file. The consumer of this type of
file must have a priori knowledge of its format and content. Because there
are no sections, there are no construction rules.
- Trying to decode the body of these files as Section header can result in
incorrect parsing.
Signed-off-by: Vineel Kovvuri[MSFT] <vineelko@microsoft.com>
- Make the Section Type: ALL as filter only, if found in Section type will return an error - Add unaligned reads to prevent undefined behavior Signed-off-by: Vineel Kovvuri[MSFT] <vineelko@microsoft.com>
9e9e9ee to
efc7452
Compare



Description
Handle RAW File types:
The current implementation tries to produce sections irrespective of the file
type. This do not hold true for RAW file types. As per PI spec below,
The file type EFI_FV_FILETYPE_RAW denotes a file that does not contain
sections and is treated as a raw data file. The consumer of this type of
file must have a priori knowledge of its format and content. Because there
are no sections, there are no construction rules.
Trying to decode the body of these files as Section header can result in
incorrect parsing.
Fixes the following bug:
Improve safety in FFS section parsing by replacing direct slice indexing with
bounds checked
get()calls and proper error propagation when buffers aremalformed. General code cleanup.
How This Was Tested
Booted to UEFI Shell on Q35
Integration Instructions
NA