Bug 280742 - ioctl on /dev/efi returns ENODEV
Summary: ioctl on /dev/efi returns ENODEV
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks: frameworklaptop
  Show dependency treegraph
 
Reported: 2024-08-11 06:53 UTC by Daniel Schaefer
Modified: 2024-08-11 14:38 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Schaefer 2024-08-11 06:53:19 UTC
I'm trying to get the ESRT system table from /dev/efi but sometimes it returns ENODEV.
The only case where that's returned is here: https://github.com/freebsd/freebsd-src/blob/7a8d05ba19b7762596c0ff22e668e4d50bac81cf/sys/dev/efidev/efirt.c#L386

lwhsu added a print to that block and found that buf->fw_resource_version sometimes contains garbage. In the UEFI spec it's specified that it must always be 1.
So we assume there is some memory corruption happening somewhere.
Comment 1 Daniel Schaefer 2024-08-11 07:12:00 UTC
Getting the ESRT is important to outd out the firmware version of devices in the system.
Here is how FWUPD calls that ioctl: https://github.com/fwupd/fwupd/blob/5f221172736fcd460441abc62ea1c399f41512c1/plugins/uefi-capsule/fu-uefi-backend-freebsd.c#L112

I'm doing the same in Rust: https://github.com/FrameworkComputer/framework-system/pull/50/files