Repository navigation
backends: fix efi_rng error check, esp_idf FFI signature, and wasi_p1 negation - #885
Open
devonjonte wants to merge 1 commit into
Open
devonjonte wants to merge 1 commit into
devonjonte wants to merge 1 commit into
Conversation
… negation - efi_rng: test the UEFI high error bit directly (matching EDK2 EFI_ERROR and Error::from_uefi_code) instead of r_efi::Status::is_error(), which masks the top two bits (0xc0) and classifies 0xC0.. high-bit statuses as success, failing open into MaybeUninit::assume_init() / unfilled buffers. - esp_idf: declare esp_fill_random returning void instead of u32 to match ESP-IDF's C prototype (void esp_fill_random(void *buf, size_t len)). - wasi_p1: match 1..=MAX_ERROR_CODE instead of code <= MAX_ERROR_CODE so negative values (in particular i32::MIN) return Error::UNEXPECTED instead of overflowing -code.
This branch has not been deployed
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.
Fixes three edge-case defects found while auditing
getrandom 0.4.3:efi_rng: high-bit UEFI error check (src/backends/efi_rng.rs)efi_rngcheckedret.is_error()viar_efi::efi::Status::is_error(), which masks the top two bits (0xc0) and requires0x80(r-efi/src/base.rs). Any high-bit status in the0xC0..reserved range returnsfalsefromis_error(), even though EDK2'sEFI_ERROR(s)(MdePkg/Include/Base.h) andgetrandom's ownError::from_uefi_code(src/error.rs) classify all high-bit-set statuses as errors.0xC0..error as success causesinit()to callprotocol.assume_init()on potentially uninitialized memory andfill_inner()to returnOk(())without fillingdest(leading to uninitialized reads infill_uninit).status.as_usize() & (1 << (usize::BITS - 1)) != 0directly keepsefi_rngconsistent withError::from_uefi_codeand fails closed.esp_idf: C FFI return type (src/backends/esp_idf.rs)void esp_fill_random(void *buf, size_t len);(components/esp_hw_support/include/esp_random.h), whereasesp_idf.rsdeclared-> u32(and discarded the value). Remove the bogus return type.wasi_p1: negative return-value negation overflow (src/backends/wasi_p1.rs)code if code <= MAX_ERROR_CODE => Err(Error::from_neg_error_code(-code))matches all negative values, soi32::MINoverflows-code(panicking with overflow checks enabled). Match1..=MAX_ERROR_CODEinstead so negative return values map toError::UNEXPECTED.