Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fw_meta: reduce raw pointer and unsafe usage #71

Merged
merged 4 commits into from
Aug 17, 2023

Commits on Aug 8, 2023

  1. fw_meta: fix metadata table length calculation

    The length field in the firmware metadata takes into account the size
    of the length field itself plus the associated UUID. To get the size
    of the contained tables, one must substract those two values. In
    parse_fw_meta_data(), this was done incorrectly due to a lack of
    parenthesis and operator precedence working from left to right.
    
    For comparison, this is already done correctly in find_table():
    
        let len = orig_len - (mem::size_of::<Uuid>() + mem::size_of::<u16>());
    
    Since the metadata is parsed backwards, the excessive computed length
    would result in accesses to the memory before the firmware metadata.
    This region would always be mapped, so no memory faults could end up
    occuring.
    
    Signed-off-by: Carlos López <[email protected]>
    00xc committed Aug 8, 2023
    Configuration menu
    Copy the full SHA
    c694693 View commit details
    Browse the repository at this point in the history
  2. fw_meta: use SvsmError when failing to parse UUIDs

    The functions that do the parsing are contained to the fw_meta module,
    so they should return errors related to firmware. This simplifies
    error handling in a few places.
    
    Signed-off-by: Carlos López <[email protected]>
    00xc committed Aug 8, 2023
    Configuration menu
    Copy the full SHA
    2d6f165 View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2023

  1. fw_meta: reduce raw pointer and unsafe usage during metadata parsing

    Refactor parse_fw_meta_data() to avoid using unsafe and raw pointers
    as much as possible. This mainly consists in properly typing the
    metadata structures and going from raw pointers to typed references
    or values as soon as possible. Since the firmware metadata comes from
    the hypervisor, it can be considered untrusted in a confidential
    computing model, so extra care is taken when using lengths and
    offsets to index into memory.
    
    Signed-off-by: Carlos López <[email protected]>
    00xc committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    95051fb View commit details
    Browse the repository at this point in the history
  2. fw_meta: add common missing derives to datatypes

    Signed-off-by: Carlos López <[email protected]>
    00xc committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    e53567e View commit details
    Browse the repository at this point in the history