Skip to content

linsysfs: expose SMBIOS DMI identification - #519

Merged
laffer1 merged 1 commit into
masterfrom
issue-518-linsysfs-dmi
Sep 25, 2026
Merged

laffer1 merged 1 commit into
masterfrom
issue-518-linsysfs-dmi

Conversation

@laffer1

@laffer1 laffer1 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add Linux-compatible /sys/class/dmi/id files backed by MidnightBSD SMBIOS kernel environment values
  • expose the common non-sensitive system, board, BIOS, and chassis vendor fields used by hardware-identification tools
  • add ATF coverage for contents, read-only permissions, and absent SMBIOS keys

Linux applications such as Geekbench probe these sysfs files before falling back to SMBIOS scanning through /dev/mem. Providing the normal Linux interface avoids the invalid fallback path reported in #518 without changing /dev/mem mmap semantics.

Fixes #518.

Validation

  • bmake -C sys/modules/linsysfs
  • bmake -C tests/sys/fs/linsysfs
  • sh -n tests/sys/fs/linsysfs/dmi_id_test.sh
  • staged cppcheck and style checks
  • bmake buildkernel KERNCONF=GENERIC including all modules

Runtime verification is pending on the Framework laptop that reproduces #518. After booting or loading the updated linsysfs module, confirm that geekbench6 --sysinfo succeeds as root and no longer opens /dev/mem.

AI contribution checklist

  • I have manually reviewed every line of AI-generated code for security flaws.
  • The code adheres to the MidnightBSD style guide.
  • No proprietary or copyleft code was introduced via the AI tool.

Summary by Sourcery

Expose SMBIOS-backed DMI identification through the linsysfs compatibility interface.

New Features:

  • Expose Linux-compatible SMBIOS DMI identification files under /sys/class/dmi/id for available system, board, BIOS, and chassis vendor information.

Bug Fixes:

  • Prevent Linux hardware-identification tools from unnecessarily falling back to /dev/mem SMBIOS scanning.

Tests:

  • Add ATF coverage for DMI file contents, read-only permissions, and handling of unavailable SMBIOS values.

Add /sys/class/dmi/id files backed by SMBIOS kernel environment values so Linux applications can use sysfs instead of falling back to /dev/mem.

Add ATF coverage for file contents, permissions, and absent SMBIOS keys.

AI-Assisted-by: Codex (GPT-5)
Signed-off-by: Lucas Holt <luke@foolishgames.com>
@sourcery-ai

sourcery-ai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR adds a Linux-compatible linsysfs DMI identification hierarchy backed by available SMBIOS kernel environment values, with dynamic read-only field files and ATF validation for contents, permissions, and missing-value behavior.

Sequence diagram for reading a linsysfs DMI field

sequenceDiagram
    participant Tool as HardwareTool
    participant Sysfs as linsysfs
    participant Kenv as KernelEnvironment

    Tool->>Sysfs: read /sys/class/dmi/id/sys_vendor
    Sysfs->>Kenv: kern_getenv(smbios.system.maker)
    Kenv-->>Sysfs: SMBIOS value
    Sysfs-->>Tool: value plus newline
Loading

Flow diagram for optional DMI field creation

flowchart TD
    INIT[linsysfs_init] --> LIST[linsysfs_listdmi]
    LIST --> CHECK[kern_getenv SMBIOS key]
    CHECK -->|value exists| CREATE[Create read-only DMI file]
    CHECK -->|value absent| OMIT[Omit DMI file]
    CREATE --> READ[linsysfs_dmi_field]
    READ --> OUTPUT[Return value plus newline]
Loading

File-Level Changes

Change Details Files
Expose selected SMBIOS identification values through the Linux-compatible /sys/class/dmi/id hierarchy.
  • Map seven non-sensitive DMI filenames to MidnightBSD SMBIOS kernel environment keys.
  • Create only files whose backing SMBIOS values are present.
  • Read values dynamically, append the sysfs-standard newline, and expose files as read-only.
sys/compat/linsysfs/linsysfs.c
Add ATF coverage for the new linsysfs DMI interface and register it with filesystem tests.
  • Load and mount linsysfs as needed, compare each exposed file with kenv, and verify read-only mode 0444.
  • Check that files are absent when corresponding SMBIOS keys are unavailable; skip hosts with no SMBIOS values.
  • Clean up the test mount and module, and include the test directory in the system filesystem suite.
tests/sys/fs/Makefile
tests/sys/fs/linsysfs/Makefile
tests/sys/fs/linsysfs/dmi_id_test.sh

Assessment against linked issues

Issue Objective Addressed Explanation
#518 Prevent Geekbench and similar Linux hardware-identification tools from falling back to SMBIOS probing through /dev/mem, thereby avoiding the root-only SIGSEGV. ✅
#518 Expose the standard Linux-compatible /sys/class/dmi/id SMBIOS identification files using available MidnightBSD SMBIOS values, while omitting fields whose values are unavailable. ✅
#518 Add regression coverage for DMI file contents, read-only permissions, and behavior when SMBIOS values are absent. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="sys/compat/linsysfs/linsysfs.c" line_range="65-73" />
<code_context>
+	const char *kenv;
+};
+
+static const struct linsysfs_dmi_field linsysfs_dmi_fields[] = {
+	{ "sys_vendor", "smbios.system.maker" },
+	{ "product_name", "smbios.system.product" },
+	{ "board_vendor", "smbios.planar.maker" },
+	{ "board_name", "smbios.planar.product" },
+	{ "bios_vendor", "smbios.bios.vendor" },
+	{ "bios_version", "smbios.bios.version" },
+	{ "chassis_vendor", "smbios.chassis.maker" },
+};
+
+TAILQ_HEAD(scsi_host_list, scsi_host_queue) scsi_host_q;
</code_context>
<issue_to_address>
**issue (broader_impact):** The `/sys/class/dmi/id` interface exposes only seven DMI attributes and omits standard fields such as `product_uuid`, `product_serial`, `product_version`, `bios_date`, `board_version`, `board_serial`, `chassis_type`, and their related fields. Linux applications that probe any of those standard paths receive `ENOENT` and can still fall back to SMBIOS scanning through `/dev/mem`, so the new interface does not reliably prevent the fallback described in the PR.

**Triggers:** When a hardware-identification application requires a standard DMI attribute not included in this table.

**Suggested fix:** Add the supported non-sensitive standard DMI attributes to `linsysfs_dmi_fields`, or explicitly limit the interface and callers to the subset that is guaranteed to be available.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +65 to +73
static const struct linsysfs_dmi_field linsysfs_dmi_fields[] = {
{ "sys_vendor", "smbios.system.maker" },
{ "product_name", "smbios.system.product" },
{ "board_vendor", "smbios.planar.maker" },
{ "board_name", "smbios.planar.product" },
{ "bios_vendor", "smbios.bios.vendor" },
{ "bios_version", "smbios.bios.version" },
{ "chassis_vendor", "smbios.chassis.maker" },
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (broader_impact): The /sys/class/dmi/id interface exposes only seven DMI attributes and omits standard fields such as product_uuid, product_serial, product_version, bios_date, board_version, board_serial, chassis_type, and their related fields. Linux applications that probe any of those standard paths receive ENOENT and can still fall back to SMBIOS scanning through /dev/mem, so the new interface does not reliably prevent the fallback described in the PR.

Triggers: When a hardware-identification application requires a standard DMI attribute not included in this table.

Suggested fix: Add the supported non-sensitive standard DMI attributes to linsysfs_dmi_fields, or explicitly limit the interface and callers to the subset that is guaranteed to be available.

@laffer1
laffer1 merged commit ae1327a into master Sep 25, 2026
5 of 11 checks passed
@laffer1
laffer1 deleted the issue-518-linsysfs-dmi branch September 25, 2026 02:15
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.

Linuxulator: Geekbench 6 SIGSEGV during SMBIOS /dev/mem probe as root

1 participant