Skip to content

Fuzz fixes - #407

Draft
JohnAZoidberg wants to merge 2 commits into
mainfrom
fuzz-fixes
Draft

JohnAZoidberg wants to merge 2 commits into
mainfrom
fuzz-fixes

Conversation

@JohnAZoidberg

Copy link
Copy Markdown
Member

No description provided.

read_memory() returns None if the platform isn't detected as Framework
or the driver fails, but many callers unwrapped it. power_info() and
get_accel_data() are also used by the UEFI app embedded in the BIOS,
where a panic stops the boot.

- read_u32/read_string return Option, add read_u8, and power_info()
  returns None if any read fails
- get_accel_data() reads the whole block at once and returns zeros and
  an unreliable lid angle if that fails
- AccelData::from doesn't index past short data
- print_sensors() doesn't index past the sensor locations the EC reported
- get_fan_num() returns an error instead of panicking
The EC sends 0xFF as board ID if it fails to read the ADC
(BOARD_VERSION_UNKNOWN). Any value we don't know would panic, which in
the UEFI app embedded in the BIOS stops the boot.

Slots can hold modules with board IDs we don't recognize, so map those
to InputModuleType::Unknown(u8). An unknown module has size 0 and an
unknown touchpad is treated as not present.

The deck state is an EC state machine value, an unknown one is an error.
Decode it with TryFrom and return an EcError from
get_input_deck_status/set_input_deck_mode instead of panicking.
--inputdeck-mode prints that error instead of unwrapping it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Malformed responses still panic in debug builds, and input-deck reset or mode-setting failures return success despite potentially leaving the deck forced off.

2 open issues
What changed in this PR

This PR hardens the library’s embedded-controller response handling against malformed data encountered during fuzzing.

Changes:

  • Validate power and sensor reads before decoding.
  • Handle unknown input modules and invalid deck states without panicking.
  • Continue input-deck reset recovery when commands report errors.
File Description
framework_lib/​src/​power.rs Adds read validation and safer sensor decoding.
framework_lib/​src/​commandline/​mod.rs Replaces input-deck command panics with error logging.
framework_lib/​src/​chromium_ec/​mod.rs Propagates input-deck decoding errors.
framework_lib/​src/​chromium_ec/​input_deck.rs Handles unknown module IDs and rejects invalid states.

Review effort: Balanced

// Make sure it has time to fully turn off
os_specific::sleep(100);
ec.set_input_deck_mode(DeckStateMode::Required).unwrap();
print_err(ec.set_input_deck_mode(DeckStateMode::Required));
);
error!("Unexpected length returned: {:?} instead of 4", bytes.len());
return 0;
return None;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants