LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
System Information: memory modules through the read-only hw-memory-modules admin action (anyone, no arguments): the SMBIOS type 17 entries parsed strictly in sysreport/smbios.c, only slot, bank, size, type, speeds and manufacturer leave the helper (never serial, asset tag or part number); Hardware → Memory → Read modules; tests with crafted and malformed tables
Federico Pereira3d120475b343
diff --git a/apps/sysinfo/index.jsx b/apps/sysinfo/index.jsxindex 0706224..48ebd5e 100644--- a/apps/sysinfo/index.jsx+++ b/apps/sysinfo/index.jsx@@ -6,10 +6,10 @@import {View, Text, ScrollView, Button, useTheme, useLocale, LordOSLogo, systemReport, systemInfo, lordosVersion, formatBytes, formatNumber,Toolbar, ToolbarSpacer, ToolbarButton, Segmented, SidebarItem, GroupBox, FormRow, EmptyState, Hairline, spacing, typeScale,- fs, userDirs, clipboard, wm,+ fs, userDirs, clipboard, wm, admin,} from '@lordos/sdk';import { useMemo, useState } from 'react';-import { cardLayers, sessionLayers, compatibility, hardwareSections, throttleFlags, machineName, compositionReason, reportFileName, reportJson } from './model.js';+import { cardLayers, sessionLayers, compatibility, hardwareSections, throttleFlags, machineName, compositionReason, reportFileName, reportJson, parseMemoryLines } from './model.js';// The app's icon: a chip on the brand gradient.export function Icon({ size: s }) {@@ -184,11 +184,14 @@ function Section({ id, r }) {<Row label={tr('sysinfo.f.microcode')} value={c.microcode} /></GroupBox>);case 'memory': return (- <GroupBox>- <Row label={tr('sysinfo.f.total')} value={formatBytes((mem.totalKB || 0) * 1024)} />- <Row label={tr('sysinfo.f.swap')} value={mem.swapKB ? formatBytes(mem.swapKB * 1024) : tr('sysinfo.none')} />- {(mem.zram || []).map((z, i) => <Row key={i} label={tr('sysinfo.f.zram')} value={`${formatBytes(z.sizeKB * 1024)}${z.algorithm ? ` · ${z.algorithm}` : ''}`} />)}- </GroupBox>);+ <View style={{ gap: spacing.xl }}>+ <GroupBox>+ <Row label={tr('sysinfo.f.total')} value={formatBytes((mem.totalKB || 0) * 1024)} />+ <Row label={tr('sysinfo.f.swap')} value={mem.swapKB ? formatBytes(mem.swapKB * 1024) : tr('sysinfo.none')} />+ {(mem.zram || []).map((z, i) => <Row key={i} label={tr('sysinfo.f.zram')} value={`${formatBytes(z.sizeKB * 1024)}${z.algorithm ? ` · ${z.algorithm}` : ''}`} />)}+ </GroupBox>+ <MemoryModules />+ </View>);case 'graphics': return <Graphics r={r} />;case 'displays': return <List items={r.displays || []} render={(d, i) => (<GroupBox key={i} title={d.connector}>@@ -267,6 +270,36 @@ function Section({ id, r }) {}}+// The memory modules come from the firmware's tables, which only root can read: the read-only+// hw-memory-modules action, on request.+function MemoryModules() {+ const t = useTheme();+ const { t: tr } = useLocale();+ const [state, setState] = useState({ busy: false, list: null, error: null });+ const read = () => {+ const lines = [];+ setState({ busy: true, list: null, error: null });+ admin.run('hw-memory-modules', '', (l) => lines.push(l), { quiet: true })+ .then(() => setState({ busy: false, list: parseMemoryLines(lines), error: null }), (e) => setState({ busy: false, list: null, error: e.message }));+ };+ const list = state.list;+ return (+ <GroupBox title={tr('sysinfo.modules.title')} footer={tr('sysinfo.modules.footer')}>+ {list && list.length ? list.map((m, i) => (+ <Row key={i} label={m.slot || tr('sysinfo.modules.slot', { n: i + 1 })}+ value={m.sizeMB ? [formatBytes(m.sizeMB * 1048576), m.type, m.speed ? tr('sysinfo.modules.speed', { mts: m.configured && m.configured !== m.speed ? `${m.configured}/${m.speed}` : m.speed }) : '', m.maker].filter(Boolean).join(' · ')+ : tr('sysinfo.modules.empty')} />+ )) : (+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: spacing.m, minHeight: 40, paddingVertical: 6 }}>+ <Text style={{ flex: 1, fontSize: typeScale.callout, color: state.error ? '#ff453a' : t.textDim, textAlign: 'start' }}>+ {state.error || (list ? tr('sysinfo.modules.none') : state.busy ? tr('sysinfo.modules.reading') : tr('sysinfo.modules.hint'))}</Text>+ <Button small label={tr('sysinfo.modules.read')} disabled={state.busy || !admin.available()} onClick={read} />+ </View>+ )}+ </GroupBox>+ );+}+function Hardware({ r }) {const t = useTheme();const { t: tr } = useLocale();diff --git a/apps/sysinfo/model.js b/apps/sysinfo/model.jsindex 5d4ffee..f093654 100644--- a/apps/sysinfo/model.js+++ b/apps/sysinfo/model.js@@ -145,3 +145,16 @@ export function reportFileName(date, ext, exists) {// The JSON a report is saved as: the collector's fields as they are, two-space indent.export const reportJson = (r) => `${JSON.stringify(r, null, 2)}\n`;++// hw-memory-modules' lines (hw/hw_admin.c, sysreport/smbios.c): "mem <size_mb>|<type>|<speed>|+// <configured>|<slot>|<bank>|<maker>", one per slot. Anything else is dropped.+export function parseMemoryLines(lines) {+ const out = [];+ for (const l of Array.isArray(lines) ? lines : []) {+ const m = /^mem (\d{1,9})\|([A-Za-z0-9]{0,11})\|(\d{1,6})\|(\d{1,6})\|([\x20-\x7e]{0,31})\|([\x20-\x7e]{0,31})\|([\x20-\x7e]{0,31})$/.exec(String(l));+ if (!m || [m[5], m[6], m[7]].some((x) => x.includes('|'))) continue;+ out.push({ sizeMB: +m[1], type: m[2], speed: +m[3], configured: +m[4], slot: m[5], bank: m[6], maker: m[7] });+ if (out.length >= 64) break;+ }+ return out;+}diff --git a/assets/locales/en/status.json b/assets/locales/en/status.jsonindex a5b1fe8..3659c00 100644--- a/assets/locales/en/status.json+++ b/assets/locales/en/status.json@@ -130,5 +130,7 @@"imager.cancelling": "Cancelling…","imager.cacheCleared": "Downloads cleared","imager.verifiedImage": "The image matches its signed SHA-256",- "imager.written": "Written and verified"+ "imager.written": "Written and verified",+ "hw.memoryRead": "Memory modules read",+ "hw.memoryNoTables": "The firmware lists no memory modules"}diff --git a/assets/locales/en/sysinfo.json b/assets/locales/en/sysinfo.jsonindex 968e6aa..b1e633f 100644--- a/assets/locales/en/sysinfo.json+++ b/assets/locales/en/sysinfo.json@@ -132,6 +132,15 @@"layout": "{sockets} × {cores} cores, {threads} threads","lordos": "LordOS {v}","lordosChannel": "LordOS {v} ({channel})",+ "modules.empty": "Empty",+ "modules.footer": "From the firmware's tables. Serial and part numbers are never read.",+ "modules.hint": "The firmware's memory tables can only be read by the system.",+ "modules.none": "The firmware lists no memory modules (common on boards without these tables, like the Raspberry Pi).",+ "modules.read": "Read modules",+ "modules.reading": "Reading…",+ "modules.slot": "Slot {n}",+ "modules.speed": "{mts} MT/s",+ "modules.title": "Memory modules","net.ethernet": "Ethernet","net.other": "Other","net.virtual": "Virtual interface",diff --git a/assets/locales/es/status.json b/assets/locales/es/status.jsonindex 0691938..b82c65c 100644--- a/assets/locales/es/status.json+++ b/assets/locales/es/status.json@@ -130,5 +130,7 @@"imager.cancelling": "Cancelando…","imager.cacheCleared": "Descargas borradas","imager.verifiedImage": "La imagen coincide con su SHA-256 firmado",- "imager.written": "Grabada y verificada"+ "imager.written": "Grabada y verificada",+ "hw.memoryRead": "Módulos de memoria leídos",+ "hw.memoryNoTables": "El firmware no informa módulos de memoria"}diff --git a/assets/locales/es/sysinfo.json b/assets/locales/es/sysinfo.jsonindex eb444b4..95f8fc7 100644--- a/assets/locales/es/sysinfo.json+++ b/assets/locales/es/sysinfo.json@@ -132,6 +132,15 @@"layout": "{sockets} × {cores} núcleos, {threads} hilos","lordos": "LordOS {v}","lordosChannel": "LordOS {v} ({channel})",+ "modules.empty": "Vacío",+ "modules.footer": "Según las tablas del firmware. Nunca se leen números de serie ni de pieza.",+ "modules.hint": "Las tablas de memoria del firmware solo las puede leer el sistema.",+ "modules.none": "El firmware no informa módulos (es normal en placas sin estas tablas, como la Raspberry Pi).",+ "modules.read": "Leer módulos",+ "modules.reading": "Leyendo…",+ "modules.slot": "Ranura {n}",+ "modules.speed": "{mts} MT/s",+ "modules.title": "Módulos de memoria","net.ethernet": "Ethernet","net.other": "Otra","net.virtual": "Interfaz virtual",diff --git a/assets/locales/pt/status.json b/assets/locales/pt/status.jsonindex 9148aab..2bd6977 100644--- a/assets/locales/pt/status.json+++ b/assets/locales/pt/status.json@@ -130,5 +130,7 @@"imager.cancelling": "Cancelando…","imager.cacheCleared": "Downloads apagados","imager.verifiedImage": "A imagem confere com o seu SHA-256 assinado",- "imager.written": "Gravada e verificada"+ "imager.written": "Gravada e verificada",+ "hw.memoryRead": "Módulos de memória lidos",+ "hw.memoryNoTables": "O firmware não informa módulos de memória"}diff --git a/assets/locales/pt/sysinfo.json b/assets/locales/pt/sysinfo.jsonindex 3935740..8e3e081 100644--- a/assets/locales/pt/sysinfo.json+++ b/assets/locales/pt/sysinfo.json@@ -132,6 +132,15 @@"layout": "{sockets} × {cores} núcleos, {threads} threads","lordos": "LordOS {v}","lordosChannel": "LordOS {v} ({channel})",+ "modules.empty": "Vazio",+ "modules.footer": "Segundo as tabelas do firmware. Números de série e de peça nunca são lidos.",+ "modules.hint": "As tabelas de memória do firmware só podem ser lidas pelo sistema.",+ "modules.none": "O firmware não informa módulos (é normal em placas sem essas tabelas, como o Raspberry Pi).",+ "modules.read": "Ler módulos",+ "modules.reading": "Lendo…",+ "modules.slot": "Slot {n}",+ "modules.speed": "{mts} MT/s",+ "modules.title": "Módulos de memória","net.ethernet": "Ethernet","net.other": "Outra","net.virtual": "Interface virtual",diff --git a/docs/BENCHMARK.md b/docs/BENCHMARK.mdindex be559a0..ff713f9 100644--- a/docs/BENCHMARK.md+++ b/docs/BENCHMARK.md@@ -268,7 +268,16 @@ existing file), with **Show in Files**. Nothing is sent anywhere: publishing com-Not yet: `hw-memory-modules`, video decode and encode and Vulkan (shown as *Not checked*), the Checks tab.+**Memory modules (2026-10-26):** Hardware → Memory → **Read modules** runs the read-only admin action+`hw-memory-modules` (the SMBIOS type 17 entries only root can read, parsed in `sysreport/smbios.c`:+slot, bank, size, type, speeds, manufacturer; never serial, asset tag or part number). On VM 116 the+parser read `mem 4096|RAM|0|0|DIMM 0||QEMU` from QEMU's real tables (`build/sysreport-test smbios` as+root); the button itself was not exercised on screen (the isolated test session has no admin helper,+so it shows disabled):++++Not yet: video decode and encode and Vulkan (shown as *Not checked*), the Checks tab.1. `server/src/sysreport/`: collector, GPU layers, `pci.ids`/EDID readers, fake-sysfs fixtures(AMD desktop, Intel laptop, Nvidia desktop, Raspberry Pi 5, VM), the anonymization test,diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex 88234bf..a778a1a 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -593,7 +593,7 @@ Details in `MAIL.md`. Tested on VM 123 against local Dovecot, Postfix and Radica- [x] collector, `pci.ids`/`usb.ids`/EDID readers, fake-sysfs fixtures, anonymization test,`lordos-sysreport report` (2026-10-26);- [x] the GPU's live layers (EGL, composition, scanout) through `lord.sysinfo` (2026-10-26);- - [ ] the read-only `hw-memory-modules` admin action;+ - [x] the read-only `hw-memory-modules` admin action (2026-10-26);- [x] Overview, Hardware and Compatibility tabs (en, es, pt; 2026-10-26; right to left not yet checked on screen);- [ ] Checks, configured and effective, with the probe app and a signed `checks.json`;- [x] reports: the Report tab with the exact text, Copy and Save to Documents (2026-10-26);diff --git a/docs/SETTINGS.md b/docs/SETTINGS.mdindex c1427ce..9a91187 100644--- a/docs/SETTINGS.md+++ b/docs/SETTINGS.md@@ -46,7 +46,8 @@ the time fields keep `direction: 'ltr'`.▼ root work: closed admin actions (hw/hw_admin.c)admin.c ─ display-brightness, power-profile, power-suspend, power-buttons, time-ntp, time-set,bt-unblock, rpi-case, video-optimize, hw-firmware-missing (the Store's suggestions,- read-only), rpi-eeprom-status (read-only), rpi-eeprom-update+ read-only), hw-memory-modules (System Information, read-only),+ rpi-eeprom-status (read-only), rpi-eeprom-updateCooling: lord.fan (ui/js_fan.c) ── /run/lordos/fand.sock ── lord-fand (root service, src/fan)```@@ -368,6 +369,7 @@ All in `server/src/hw/hw_admin.c`, in the `actions` table through `HW_ADMIN_ACTI| `rpi-eeprom-status` | — | anyone | BCM2712 boards only, read-only: `/usr/bin/rpi-eeprom-update` (no options), report parsed strictly; `OK <uptodate\|available\|pending> <current> <latest> <release>` (see "Board firmware") || `rpi-eeprom-update` | — | admin | BCM2712 boards only: `/usr/bin/rpi-eeprom-update -A bootloader`, then the same report; the update is finished by the next restart || `hw-firmware-missing` | — | anyone | read-only: reads `/dev/kmsg` and returns only the validated names of firmware files a driver asked for and that are still missing (`LOG fw <file> <driver>`), for Store → Discover's suggestions (`hw/hwscan.c`, see `PACKAGES.md`) |+| `hw-memory-modules` | — | anyone | read-only: parses the firmware's SMBIOS memory devices (`/sys/firmware/dmi/entries/17-<n>/raw`, root only) strictly in C (`sysreport/smbios.c`) and returns one `LOG mem <size_mb>\|<type>\|<speed>\|<configured>\|<slot>\|<bank>\|<maker>` line per slot; serials, asset tags and part numbers are never read (System Information → Hardware → Memory, see `BENCHMARK.md`) |The validators are unit-tested in `build/settings-hw-test`.diff --git a/docs/sysinfo-memory.png b/docs/sysinfo-memory.pngnew file mode 100644index 0000000..6c4bacbBinary files /dev/null and b/docs/sysinfo-memory.png differdiff --git a/server/mk/settings.mk b/server/mk/settings.mkindex d505e5a..c9acda3 100644--- a/server/mk/settings.mk+++ b/server/mk/settings.mk@@ -3,7 +3,7 @@# Objects are added to lord-server as extra prerequisites ($^ in its link rule takes them).HW_SRC := src/hw/edid.c src/hw/modes.c src/hw/night.c src/hw/mimeapps.c src/hw/power.c src/hw/jbuf.c src/hw/display.c \src/hw/uevent.c src/hw/sysbus.c src/hw/bt.c src/hw/ppd.c src/hw/hw.c src/hw/hw_admin.c src/hw/defaults.c src/hw/notifyd.c src/hw/hwscan.c src/hw/brframe.c src/ui/js_hw.c \- src/sysreport/sysreport.c src/sysreport/sysreport_out.c src/sysreport/ids.c \+ src/sysreport/sysreport.c src/sysreport/sysreport_out.c src/sysreport/ids.c src/sysreport/smbios.c \src/ui/js_fan.c src/fan/fancurve.cHW_HDR := $(wildcard src/hw/*.h) $(wildcard src/sysreport/*.h) $(wildcard src/fan/*.h) src/ui/js_hw.h src/ui/js_fan.h src/kms.h src/vault/dbus.hHW_OBJ := $(HW_SRC:src/%.c=build/obj/%.o)@@ -12,9 +12,9 @@ build/lord-server: $(HW_OBJ)# pure parts: EDID, mode selection, gamma/temperature/sun math, mimeapps.list and globs2, power_supply,# and the admin actions' validatorstest: build/settings-hw-test-build/settings-hw-test: tests/settings_hw_test.c src/hw/edid.c src/hw/modes.c src/hw/night.c src/hw/mimeapps.c src/hw/power.c src/hw/hw_admin.c src/hw/hwscan.c src/hw/jbuf.c src/sec/json.c $(HW_HDR)+build/settings-hw-test: tests/settings_hw_test.c src/hw/edid.c src/hw/modes.c src/hw/night.c src/hw/mimeapps.c src/hw/power.c src/hw/hw_admin.c src/hw/hwscan.c src/sysreport/smbios.c src/hw/jbuf.c src/sec/json.c $(HW_HDR)@mkdir -p build- $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/settings_hw_test.c src/hw/edid.c src/hw/modes.c src/hw/night.c src/hw/mimeapps.c src/hw/power.c src/hw/hw_admin.c src/hw/hwscan.c src/hw/jbuf.c src/sec/json.c -lm+ $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/settings_hw_test.c src/hw/edid.c src/hw/modes.c src/hw/night.c src/hw/mimeapps.c src/hw/power.c src/hw/hw_admin.c src/hw/hwscan.c src/sysreport/smbios.c src/hw/jbuf.c src/sec/json.c -lm./$@ || { rm -f $@; exit 1; }# BlueZ parsing (GetManagedObjects, PropertiesChanged, Battery1, paths, state JSON) without a bustest: build/bt-testdiff --git a/server/mk/sysreport.mk b/server/mk/sysreport.mkindex 280ae34..b3d0a7d 100644--- a/server/mk/sysreport.mk+++ b/server/mk/sysreport.mk@@ -1,7 +1,7 @@# System Information (0.8.5, src/sysreport, docs/BENCHMARK.md): the collector, shared by the# `lordos-sysreport` and `lordos-fetch` commands (one binary; build/lordos-fetch is a link) and# (later) lord.sysinfo. Read-only, no root, libc only.-SYSREPORT_SRC := src/sysreport/sysreport.c src/sysreport/fetch.c src/sysreport/sysreport_out.c src/sysreport/ids.c src/hw/edid.c src/hw/jbuf.c src/sec/json.c+SYSREPORT_SRC := src/sysreport/sysreport.c src/sysreport/fetch.c src/sysreport/smbios.c src/sysreport/sysreport_out.c src/sysreport/ids.c src/hw/edid.c src/hw/jbuf.c src/sec/json.cSYSREPORT_HDR := $(wildcard src/sysreport/*.h) src/hw/edid.h src/hw/jbuf.h src/sec/json.hall: build/lordos-sysreport build/lordos-fetchbuild/lordos-fetch: build/lordos-sysreportdiff --git a/server/src/hw/hw_admin.c b/server/src/hw/hw_admin.cindex e259a97..04f5c6e 100644--- a/server/src/hw/hw_admin.c+++ b/server/src/hw/hw_admin.c@@ -1,6 +1,7 @@/* hw_admin.c — Settings' admin actions (see hw_admin.h). Runs as root in the admin helper. */#include "hw_admin.h"#include "hwscan.h"+#include "../sysreport/smbios.h"#include <ctype.h>#include <dirent.h>@@ -404,6 +405,36 @@ void hw_act_firmware_missing(const AdminReq *r, const char *arg, size_t len) {admin_ok("hw.firmwareChecked", NULL);}+/* ---- System Information's memory modules (sysreport/smbios.c, docs/BENCHMARK.md) ---- */++void hw_act_memory_modules(const AdminReq *r, const char *arg, size_t len) {+ (void)r; (void)arg;+ if (len) { admin_err("admin.invalidArgument", NULL); return; }+ DIR *d = opendir("/sys/firmware/dmi/entries");+ if (!d) { admin_ok("hw.memoryNoTables", NULL); return; }+ struct dirent *e;+ int n = 0;+ while ((e = readdir(d)) && n < 64) {+ /* "17-<n>" only: the memory devices */+ if (strncmp(e->d_name, "17-", 3) || !e->d_name[3] || strspn(e->d_name + 3, "0123456789") != strlen(e->d_name + 3)) continue;+ char p[128];+ snprintf(p, sizeof p, "/sys/firmware/dmi/entries/%.32s/raw", e->d_name);+ int fd = open(p, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);+ if (fd < 0) continue;+ uint8_t buf[4096];+ ssize_t got = read(fd, buf, sizeof buf);+ close(fd);+ SmMem m;+ if (got <= 0 || smbios_memory_parse(buf, (size_t)got, &m)) continue;+ char line[256];+ smbios_memory_line(&m, line, sizeof line);+ admin_say("LOG", "%s", line); /* i18n-ok: protocol line parsed by apps/sysinfo/model.js */+ n++;+ }+ closedir(d);+ admin_ok("hw.memoryRead", NULL);+}+/* ---- video in the browser (docs/VIDEO.md) ---- */int hw_video_files(const char *arg, char *chromium, size_t cn, char *firefox, size_t fn) {diff --git a/server/src/hw/hw_admin.h b/server/src/hw/hw_admin.hindex 39d00ef..1311e81 100644--- a/server/src/hw/hw_admin.h+++ b/server/src/hw/hw_admin.h@@ -24,6 +24,11 @@* only the validated names of firmware files a driver asked* for and that are still missing, as "LOG fw <file> <driver>"* lines (the Store's suggestions, hwscan.c); read-only anyone+ * hw-memory-modules (no arguments) the memory modules from the SMBIOS tables+ * (/sys/firmware/dmi/entries/17-<n>/raw, root only), parsed+ * strictly in C (sysreport/smbios.c): one "LOG mem <size_mb>|+ * <type>|<speed>|<configured>|<slot>|<bank>|<maker>" line per slot,+ * never serials, asset tags or part numbers; read-only anyone* video-optimize <mode> <lower> <vp9> <av1> auto|always|never, on|off, yes|no, yes|no (the* last two: hardware VP9/AV1 decoding found this boot).* Writes the browsers' video settings from fixed text:@@ -44,6 +49,7 @@ void hw_act_time_set(const AdminReq *r, const char *arg, size_t len);void hw_act_bt_unblock(const AdminReq *r, const char *arg, size_t len);void hw_act_rpi_case(const AdminReq *r, const char *arg, size_t len);void hw_act_firmware_missing(const AdminReq *r, const char *arg, size_t len);+void hw_act_memory_modules(const AdminReq *r, const char *arg, size_t len);void hw_act_eeprom_status(const AdminReq *r, const char *arg, size_t len);void hw_act_eeprom_update(const AdminReq *r, const char *arg, size_t len);/* rpi-eeprom-update's report, parsed (exposed for tests) */@@ -75,6 +81,7 @@ int hw_backlight_name_valid(const char *n);{ "bt-unblock", hw_act_bt_unblock, A_ANYONE }, \{ "rpi-case", hw_act_rpi_case, 0 }, \{ "hw-firmware-missing", hw_act_firmware_missing, A_ANYONE }, \+ { "hw-memory-modules", hw_act_memory_modules, A_ANYONE }, \{ "rpi-eeprom-status", hw_act_eeprom_status, A_ANYONE | A_FORK }, \{ "rpi-eeprom-update", hw_act_eeprom_update, A_FORK }, \{ "video-optimize", hw_act_video, A_ANYONE },diff --git a/server/src/sysreport/smbios.c b/server/src/sysreport/smbios.cnew file mode 100644index 0000000..b25e6aa--- /dev/null+++ b/server/src/sysreport/smbios.c@@ -0,0 +1,90 @@+/* smbios.c — SMBIOS type 17 (Memory Device) reader, see smbios.h. Offsets from the SMBIOS+ * specification (DSP0134): 0x0C size, 0x10 device locator, 0x11 bank locator, 0x12 memory type,+ * 0x15 speed (2.3+), 0x17 manufacturer (2.3+), 0x1C extended size (2.7+), 0x20 configured speed+ * (2.7+), 0x54/0x58 extended speeds (3.3+). */+#include "smbios.h"++#include <stdio.h>+#include <string.h>++static unsigned u16(const uint8_t *p) { return (unsigned)p[0] | (unsigned)p[1] << 8; }+static unsigned long u32(const uint8_t *p) { return (unsigned long)u16(p) | (unsigned long)u16(p + 2) << 16; }++/* String number idx (1-based) of the set that starts at s and ends at end (the set ends with+ * "\0\0"). Copied as printable ASCII, '|' replaced, trimmed; placeholders become "". */+static void str_at(const uint8_t *s, const uint8_t *end, unsigned idx, char *out, size_t n) {+ out[0] = 0;+ if (!idx) return;+ for (unsigned i = 1; s < end && *s; i++) {+ const uint8_t *e = memchr(s, 0, (size_t)(end - s));+ if (!e) return;+ if (i == idx) {+ size_t o = 0;+ while (s < e && *s == ' ') s++;+ for (; s < e && o + 1 < n; s++) out[o++] = (*s >= 0x20 && *s < 0x7f && *s != '|') ? (char)*s : '?';+ while (o && out[o - 1] == ' ') o--;+ out[o] = 0;+ static const char *junk[] = { "Unknown", "UNKNOWN", "Not Specified", "NO DIMM", "None", "Undefined",+ "To Be Filled By O.E.M.", "Manufacturer00", "0000", "00000000" };+ for (size_t j = 0; j < sizeof junk / sizeof junk[0]; j++) if (!strcmp(out, junk[j])) out[0] = 0;+ return;+ }+ s = e + 1;+ }+}++static const char *mem_type(unsigned t) {+ switch (t) {+ case 0x07: return "RAM";+ case 0x0F: return "SDRAM";+ case 0x12: return "DDR";+ case 0x13: return "DDR2";+ case 0x18: return "DDR3";+ case 0x1A: return "DDR4";+ case 0x1B: return "LPDDR";+ case 0x1C: return "LPDDR2";+ case 0x1D: return "LPDDR3";+ case 0x1E: return "LPDDR4";+ case 0x22: return "DDR5";+ case 0x23: return "LPDDR5";+ case 0x00: case 0x01: case 0x02: return "";+ default: return "other";+ }+}++int smbios_memory_parse(const uint8_t *raw, size_t len, SmMem *m) {+ memset(m, 0, sizeof *m);+ if (!raw || len < 0x15 || raw[0] != 17) return -1;+ size_t fl = raw[1]; /* the formatted area's length */+ if (fl < 0x15 || fl > len) return -1;+ const uint8_t *strs = raw + fl, *end = raw + len;+ /* the string set must end with a double NUL inside the buffer */+ int closed = 0;+ for (const uint8_t *p = strs; p + 1 < end; p++) if (!p[0] && !p[1]) { closed = 1; end = p + 1; break; }+ if (!closed) return -1;++ unsigned size = u16(raw + 0x0C);+ if (size == 0xFFFF) m->size_mb = 0; /* unknown: treated as empty */+ else if (size == 0x7FFF && fl >= 0x20) m->size_mb = (unsigned)(u32(raw + 0x1C) & 0x7FFFFFFFul);+ else if (size & 0x8000) m->size_mb = (size & 0x7FFF) / 1024; /* in KB */+ else m->size_mb = size;+ str_at(strs, end, raw[0x10], m->slot, sizeof m->slot);+ str_at(strs, end, raw[0x11], m->bank, sizeof m->bank);+ snprintf(m->type, sizeof m->type, "%s", mem_type(raw[0x12]));+ if (fl >= 0x17) {+ m->speed = u16(raw + 0x15);+ if (m->speed == 0xFFFF && fl >= 0x58) m->speed = (unsigned)u32(raw + 0x54);+ }+ if (fl >= 0x18) str_at(strs, end, raw[0x17], m->maker, sizeof m->maker);+ if (fl >= 0x22) {+ m->configured = u16(raw + 0x20);+ if (m->configured == 0xFFFF && fl >= 0x5C) m->configured = (unsigned)u32(raw + 0x58);+ }+ if (m->speed > 100000) m->speed = 0;+ if (m->configured > 100000) m->configured = 0;+ return 0;+}++void smbios_memory_line(const SmMem *m, char *out, size_t n) {+ snprintf(out, n, "mem %u|%s|%u|%u|%s|%s|%s", m->size_mb, m->type, m->speed, m->configured, m->slot, m->bank, m->maker);+}diff --git a/server/src/sysreport/smbios.h b/server/src/sysreport/smbios.hnew file mode 100644index 0000000..528dc7e--- /dev/null+++ b/server/src/sysreport/smbios.h@@ -0,0 +1,29 @@+/* smbios.h — the memory modules from the firmware's SMBIOS tables (type 17, "Memory Device"), for+ * System Information (docs/BENCHMARK.md). The kernel exposes each entry as+ * /sys/firmware/dmi/entries/17-<n>/raw, readable by root only, so the read runs in the admin helper's+ * read-only action `hw-memory-modules` (hw/hw_admin.c) and only these fields leave it: slot, bank,+ * size, type, speed, configured speed and manufacturer. Serial numbers, asset tags and part numbers+ * are never read. The parser takes untrusted bytes: every offset and string index is checked. */+#ifndef LORD_SYSREPORT_SMBIOS_H+#define LORD_SYSREPORT_SMBIOS_H++#include <stddef.h>+#include <stdint.h>++typedef struct {+ char slot[32], bank[32]; /* device and bank locators ("DIMM_A1", "BANK 0") */+ unsigned size_mb; /* 0: an empty slot */+ char type[12]; /* "DDR4", "LPDDR5", "other", "" unknown */+ unsigned speed, configured; /* MT/s, 0 unknown */+ char maker[32]; /* "" unknown or not filled in by the firmware */+} SmMem;++/* Parses one raw type-17 structure (formatted area + its string set). 0, or -1 if it isn't one or+ * is malformed. Strings come out as printable ASCII without '|', placeholders ("Unknown",+ * "Not Specified", "To Be Filled By O.E.M."…) as "". */+int smbios_memory_parse(const uint8_t *raw, size_t len, SmMem *m);++/* The action's line for one module: "mem <size_mb>|<type>|<speed>|<configured>|<slot>|<bank>|<maker>". */+void smbios_memory_line(const SmMem *m, char *out, size_t n);++#endifdiff --git a/server/tests/sysinfo_model_test.mjs b/server/tests/sysinfo_model_test.mjsindex 58df5d1..1d20bf8 100644--- a/server/tests/sysinfo_model_test.mjs+++ b/server/tests/sysinfo_model_test.mjs@@ -1,7 +1,7 @@// sysinfo_model_test.mjs — System Information's model (apps/sysinfo/model.js, 0.8.5): the GPU layers,// the reasons for CPU composition, the Compatibility panel and the Hardware sections. Run by// tests/run_suites.sh (needs node).-import { compositionReason, cardLayers, sessionLayers, compatibility, hardwareSections, throttleFlags, machineName, reportFileName, reportJson } from '../../apps/sysinfo/model.js';+import { compositionReason, cardLayers, sessionLayers, compatibility, hardwareSections, throttleFlags, machineName, reportFileName, reportJson, parseMemoryLines } from '../../apps/sysinfo/model.js';let n = 0, bad = 0;const eq = (what, got, want) => {@@ -89,5 +89,13 @@ eq('a strange date never reaches the name', reportFileName('../../x', 'md', () =eq('all taken', reportFileName('2026-10-26', 'md', () => true), null);eq('json text', reportJson({ schema: 1, cpu: { cores: 8 } }), '{\n "schema": 1,\n "cpu": {\n "cores": 8\n }\n}\n');+// ---- memory modules ----+eq('module lines', parseMemoryLines(['mem 16384|DDR4|3200|2666|DIMM_A1|BANK 0|Kingston', 'mem 0||0|0|DIMM_B1||', 'mem 4096|RAM|0|0|DIMM 0||QEMU']), [+ { sizeMB: 16384, type: 'DDR4', speed: 3200, configured: 2666, slot: 'DIMM_A1', bank: 'BANK 0', maker: 'Kingston' },+ { sizeMB: 0, type: '', speed: 0, configured: 0, slot: 'DIMM_B1', bank: '', maker: '' },+ { sizeMB: 4096, type: 'RAM', speed: 0, configured: 0, slot: 'DIMM 0', bank: '', maker: 'QEMU' }]);+eq('bad lines dropped', parseMemoryLines(['fw x y', 'mem 1|DDR4|1|1|a|b', 'mem x|DDR4|1|1|a|b|c', 'mem 1|DDR4|1|1|a|b|c|d', `mem 1|DDR4|1|1|${'a'.repeat(40)}|b|c`, null]), []);+eq('not a list', parseMemoryLines(undefined), []);+console.log(`sysinfo-model-test: ${n - bad} ok, ${bad} failed`);process.exit(bad ? 1 : 0);diff --git a/server/tests/sysreport_test.c b/server/tests/sysreport_test.cindex b44187e..5a19253 100644--- a/server/tests/sysreport_test.c+++ b/server/tests/sysreport_test.c@@ -8,11 +8,14 @@* lordos-fetch's summary is checked on the same trees: with --share it carries none of those values* either, and without color it has no escape codes.*+ * build/sysreport-test smbios the memory module lines of this machine, as the+ * hw-memory-modules action gives them (root)* build/sysreport-test fixture <dir> <kind> writes a fake tree (amd, intel, nvidia, rpi5, vm), for* `lordos-sysreport report --root <dir>` */#include "sysreport/sysreport.h"#include "sysreport/ids.h"#include "sysreport/fetch.h"+#include "sysreport/smbios.h"#include "sec/json.h"#include <errno.h>@@ -523,6 +526,57 @@ static void test_fetch(const char *kind) {rmtree(root);}+/* A type-17 structure: formatted area of fl bytes, then the strings. */+static size_t smb17(uint8_t *b, int fl, unsigned size, unsigned type, unsigned speed, unsigned cfg, const char **strs, int nstr) {+ memset(b, 0, 512);+ b[0] = 17; b[1] = (uint8_t)fl; b[2] = 0x10;+ b[0x0C] = (uint8_t)size; b[0x0D] = (uint8_t)(size >> 8);+ b[0x10] = 1; b[0x11] = 2; b[0x12] = (uint8_t)type;+ b[0x15] = (uint8_t)speed; b[0x16] = (uint8_t)(speed >> 8);+ b[0x17] = 3; b[0x18] = 4; b[0x19] = 5; b[0x1A] = 6; /* manufacturer, serial, asset tag, part number */+ if (fl >= 0x22) { b[0x20] = (uint8_t)cfg; b[0x21] = (uint8_t)(cfg >> 8); }+ size_t o = (size_t)fl;+ for (int i = 0; i < nstr; i++) { size_t l = strlen(strs[i]); memcpy(b + o, strs[i], l); o += l + 1; }+ b[o++] = 0;+ return o;+}++static void test_smbios(void) {+ uint8_t b[512];+ SmMem m;+ const char *s1[] = { "DIMM_A1", "BANK 0", "Kingston", "SECRET-SERIAL-9", "SECRET-ASSET", "SECRETPART-1" };+ size_t n = smb17(b, 0x28, 16384, 0x1A, 3200, 2666, s1, 6);+ CHECK(!smbios_memory_parse(b, n, &m), "smbios: parse");+ CHECK(m.size_mb == 16384 && !strcmp(m.type, "DDR4") && m.speed == 3200 && m.configured == 2666, "smbios: size/type/speed %u %s %u %u", m.size_mb, m.type, m.speed, m.configured);+ CHECK(!strcmp(m.slot, "DIMM_A1") && !strcmp(m.bank, "BANK 0") && !strcmp(m.maker, "Kingston"), "smbios: strings %s|%s|%s", m.slot, m.bank, m.maker);+ char line[256];+ smbios_memory_line(&m, line, sizeof line);+ CHECK(!strcmp(line, "mem 16384|DDR4|3200|2666|DIMM_A1|BANK 0|Kingston"), "smbios: line %s", line);+ CHECK(!strstr(line, "SECRET"), "smbios: no serial, asset tag or part number");+ const char *s2[] = { "ChannelA-DIMM1", "BANK 1", "Not Specified" };+ n = smb17(b, 0x22, 0x7FFF, 0x22, 0xFFFF, 0, s2, 3);+ b[0x1C] = 0x00; b[0x1D] = 0x80; b[0x1E] = 0; b[0x1F] = 0; /* extended size: 32768 MB */+ CHECK(!smbios_memory_parse(b, n, &m) && m.size_mb == 32768 && !strcmp(m.type, "DDR5") && !m.maker[0], "smbios: extended size, placeholder maker");+ const char *s3[] = { "DIMM 1", "", "Unknown" };+ n = smb17(b, 0x1B, 0, 0x02, 0, 0, s3, 3);+ CHECK(!smbios_memory_parse(b, n, &m) && m.size_mb == 0 && !m.type[0] && !strcmp(m.slot, "DIMM 1"), "smbios: an empty slot");+ n = smb17(b, 0x22, 0x8000 | 2048, 0x1E, 4266, 4266, s1, 3);+ CHECK(!smbios_memory_parse(b, n, &m) && m.size_mb == 2 && !strcmp(m.type, "LPDDR4"), "smbios: size in KB");+ const char *s4[] = { "A|B", "x" };+ n = smb17(b, 0x1B, 8192, 0x1A, 0, 0, s4, 2);+ b[0x17] = 9; /* a string index past the set */+ CHECK(!smbios_memory_parse(b, n, &m) && !strcmp(m.slot, "A?B") && !m.maker[0], "smbios: '|' replaced, missing string empty");+ /* malformed */+ n = smb17(b, 0x28, 8192, 0x1A, 0, 0, s1, 6);+ CHECK(smbios_memory_parse(b, n - 1, &m) == -1, "smbios: string set without its double NUL");+ CHECK(smbios_memory_parse(b, 0x10, &m) == -1, "smbios: too short");+ b[0] = 16;+ CHECK(smbios_memory_parse(b, n, &m) == -1, "smbios: another type");+ b[0] = 17; b[1] = 0xFF;+ CHECK(smbios_memory_parse(b, 0x40, &m) == -1, "smbios: formatted length past the buffer");+ CHECK(smbios_memory_parse(NULL, 100, &m) == -1, "smbios: NULL");+}+static void test_empty(void) {char root[] = "/tmp/sysreport-empty-XXXXXX";if (!mkdtemp(root)) { printf("mkdtemp\n"); exit(2); }@@ -534,12 +588,29 @@ static void test_empty(void) {}int main(int argc, char **argv) {+ if (argc == 2 && !strcmp(argv[1], "smbios")) {+ for (int i = 0; i < 64; i++) {+ char p[96], line[256];+ snprintf(p, sizeof p, "/sys/firmware/dmi/entries/17-%d/raw", i);+ FILE *f = fopen(p, "rb");+ if (!f) break;+ uint8_t b[4096];+ size_t n = fread(b, 1, sizeof b, f);+ fclose(f);+ SmMem m;+ if (smbios_memory_parse(b, n, &m)) { printf("17-%d: malformed\n", i); continue; }+ smbios_memory_line(&m, line, sizeof line);+ printf("%s\n", line);+ }+ return 0;+ }if (argc == 4 && !strcmp(argv[1], "fixture")) {mkdirs(argv[2]);fixture(argv[2], argv[3]);return 0;}test_ids();+ test_smbios();const char *kinds[] = { "amd", "intel", "nvidia", "rpi5", "vm" };for (size_t i = 0; i < sizeof kinds / sizeof kinds[0]; i++) { test_kind(kinds[i]); test_fetch(kinds[i]); }setenv("NO_COLOR", "1", 1);