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
Raspberry Pi: Bluetooth on the Pi 5 image (BlueZ, firmware, SCO helper), "No Bluetooth" enforced with the BPF LSM kernel; verify-board checks; docs
Federico Pereira02413e632946
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 99b367d..5392edc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -30,6 +30,15 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),lets you allow all users or only administrators. Root never logs in (`PermitRootLogin no` in adrop-in shipped by the `lordos` package). The Raspberry Pi image's `ssh` switch file keepsworking and shows up as on ([docs/REMOTE.md](docs/REMOTE.md#remote-login-ssh)).+- **Bluetooth on the Raspberry Pi 5 image.** The on-board CYW43455 controller (on a UART, brought+ up by the kernel) now works out of the box: the image ships BlueZ, the chip's firmware patch+ (`bluez-firmware`), headset audio in PipeWire (`libspa-0.2-bluetooth`) and a small helper of our+ own, `lordos-rpi-bt@hciN`, that routes call audio (SCO) over HCI so headset microphones work.+ Settings → Bluetooth uses it as on a PC. Scanning is verified on a Pi 5; pairing a device on the+ board is still to be tested ([docs/RASPBERRY.md](docs/RASPBERRY.md#bluetooth)).+- **`verify-board` checks Bluetooth and the BPF LSM** on a freshly flashed board: the controller on+ its UART, `bluetoothd`, the SCO helper, the board address, `bpf` in the LSM list, the kernel's+ BTF and `lord-netperm`.- **Guest tools on VMware.** The ISO (and so every installed system) ships `open-vm-tools`:shutdown and restart from the hypervisor, time sync and the guest's IP address. Its services onlyrun under VMware. Shared clipboard and automatic screen resize are not supported yet@@ -37,6 +46,10 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),### Changed+- **The LordOS Raspberry Pi kernel gains the BPF LSM, BTF and Yama** (`6.18.57-2+lordos`, same+ Raspberry Pi source as 0.8.0's `-1`): `CONFIG_BPF_LSM`, `CONFIG_DEBUG_INFO_BTF` (from `pahole`;+ modules stripped, no debug package) and `CONFIG_SECURITY_YAMA`. The active LSM list on the Pi is+ now `capability,landlock,yama,bpf`.- **Monitor → Network: a fluid traffic chart.** The sparse per-second bars are now a continuousmirrored strip for the last 60 s: sent above the baseline, received below, one bar per second ona faint track, scrolling smoothly at 4 samples per second, auto-scaled, with the minute's totals@@ -65,6 +78,12 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),bar < fullscreen < launcher < menus and popovers < sheets < notifications < tooltips < dragimages < system prompts), and clicks follow it, in every Dock position, light and dark, RTL andthe Classic theme ([docs/LAYERS.md](docs/LAYERS.md)).+- **"No Bluetooth" for Linux apps is enforced on the Raspberry Pi 5** (a known issue in 0.8.0):+ `lord-netperm` loads its Bluetooth socket program there as on a PC (`npverify-test` 37/37 on the+ board), and a process in a restricted app's scope gets `EPERM` from `socket(AF_BLUETOOTH)` while+ the same call outside it works.+- **`kernel.yama.ptrace_scope = 1` applies on the Raspberry Pi 5:** 0.8.0's Pi kernel had no Yama,+ so any process could attach to another of the same user there.- **The menu bar names a Linux app, not its window.** Next to the crown it showed the window title(for a browser, the whole page title); it now shows the app's shortname, "Chromium", in every language. The Dock tooltip and Linux app notifications use the samediff --git a/docs/FIREWALL.md b/docs/FIREWALL.mdindex 5b9fe91..d028dbd 100644--- a/docs/FIREWALL.md+++ b/docs/FIREWALL.md@@ -216,6 +216,14 @@ distributed under the GPL); the others keep "LordOS". If the kernel refuses theBluetooth program, the network ones still work and the status says `"devices":false` or`"bluetooth":false`.+On the Raspberry Pi 5 this needs the LordOS kernel from 0.8.1 on (`6.18.57-2+lordos`, built with+`CONFIG_BPF_LSM` and BTF; see `RASPBERRY.md`, "The LordOS kernel"). 0.8.0's Pi kernel had neither,+so there `lord-netperm` reported `"bluetooth":false` and "No Bluetooth" wasn't enforced. Tested on+a Pi 5 (2026-10-18): `lord-netperm: 9 BPF programs loaded (devices: yes, Bluetooth sockets: yes)`,+`npverify-test` 37/37, and the steps of `tests/fwlinux/bluetooth.sh` (as root, for the board's+user): `socket(AF_BLUETOOTH)` in the restricted app's scope → `EPERM`, inet and unix sockets there+still work, the same call outside the scope works, and lifting the restriction gives it back.+*Not covered:* BlueZ over D-Bus. An app can still ask `bluetoothd` on the system bus (`org.bluez`)to scan, pair and connect, and a profile it registers gets its connected socket from `bluetoothd`.The system bus policy can't tell two apps of the same user apart; mediating it per app needs adiff --git a/docs/RASPBERRY.md b/docs/RASPBERRY.mdindex 1cf2a75..a115b83 100644--- a/docs/RASPBERRY.md+++ b/docs/RASPBERRY.md@@ -51,7 +51,7 @@ SD card or an NVMe, and the same image boots on the Pi 5 and the Pi 4.wpa_supplicant, OpenVPN, Noto, foot, FeatherPad.- **The LordOS build of the Raspberry Pi kernel** (see "The LordOS kernel"), when`tools/rpi/build-kernel.sh` has built it; otherwise Raspberry Pi's archive kernel, with a loud- warning (it has no Landlock):+ warning (it has no Landlock, BPF LSM or BTF):- `linux-image-<version>-lordos-rpi-2712`: the Pi 5 one, with 16K pages (archive:`linux-image-rpi-2712`);- `linux-image-<version>-lordos-rpi-v8`: the Pi 4/400/CM4 one, with 4K pages (archive:@@ -59,10 +59,13 @@ SD card or an NVMe, and the same image boots on the Pi 5 and the Pi 4.- **Firmware from the Raspberry Pi archive** (`archive.raspberrypi.com/debian`, suite trixie), onlythese packages (`/etc/apt/preferences.d/raspberrypi`):- `raspi-firmware`: the boot files, device trees and overlays in `/boot/firmware`;- - `firmware-brcm80211`: Wi-Fi and Bluetooth (CYW43455);+ - `firmware-brcm80211`: Wi-Fi (CYW43455);- `rpi-eeprom` and `raspi-utils` (`vcgencmd`, `pinctrl`), if available.Everything else comes from Debian, Mesa included.+- **Bluetooth** (the CYW43455's Bluetooth half, on a UART; see "Bluetooth"), from Debian: `bluez`,+ `bluez-firmware` (the chip's patch, `brcm/BCM4345C0.hcd`), `libspa-0.2-bluetooth` (headsets in+ PipeWire) and `rfkill`, plus our SCO-routing helper (`lordos-rpi-bt@hciN`).- **Debian 13's Mesa:** v3d (GLES 3.1), v3dv (Vulkan) and kmsro (vc4 for the display, v3d forrendering). lord-server is compiled with `GPU=1`.- **The same LordOS package as the ISO.** Built by `tools/iso/mkdeb.sh` with `DEB_ARCH=arm64`.@@ -102,23 +105,26 @@ Pi, and everything else from Debian. The kernel is LordOS's own build of it (nexRaspberry Pi's kernel leaves Landlock out (`# CONFIG_SECURITY_LANDLOCK is not set`, `CONFIG_LSM=""`,so `/sys/kernel/security/lsm` is just `capability`). LordOS confines apps (`.lpk`) and its helpers(`lord-doc`, `lord-media`, `lord-maild`) with Landlock (`server/src/sec/sandbox.c`, see-`PRIVACY.md`); without it `doc_evil.sh` fails 5 of 25 and `sandbox-test` is skipped. The tests stay-as they are: the fix is the kernel.+`PRIVACY.md`); without it `doc_evil.sh` fails 5 of 25 and `sandbox-test` is skipped. It also has no+BPF LSM and no BTF (`/sys/kernel/btf/vmlinux`), which `lord-netperm` needs for "No Bluetooth" of+Linux apps (its per-cgroup LSM program on `socket_create`, `FIREWALL.md`); without them+`npverify-test` fails 35/36. The tests stay as they are: the fix is the kernel.`tools/rpi/build-kernel.sh` builds it from **Raspberry Pi's own source and defconfig**, changing onlywhat LordOS needs:```sh-# on the Pi (arm64 Debian 13): about 50 min per flavour on a Pi 5 (4 cores, SD card, Active Cooler)+# on the Pi (arm64 Debian 13): about 75 min per flavour on a Pi 5 (4 cores, SD card), ~10 GB freesudo apt-get install -y --no-install-recommends build-essential bc bison flex libssl-dev libelf-dev \libdw-dev dwarves cpio kmod rsync dpkg-dev debhelper gittools/rpi/build-kernel.sh /var/tmp/lordos-kernel all # 2712 (Pi 5), v8 (Pi 4), or all-# → /var/tmp/lordos-kernel/out/linux-image-6.18.57-lordos-rpi-2712_6.18.57-1+lordos_arm64.deb, …+# → /var/tmp/lordos-kernel/out/linux-image-6.18.57-lordos-rpi-2712_6.18.57-2+lordos_arm64.deb, …```- **Source:** `github.com/raspberrypi/linux`, branch `rpi-6.18.y` (`RPI_KERNEL_BRANCH`;`RPI_KERNEL_REF=<commit>` pins one). The first build (2026-10-18) used commit `234188315037`,- kernel **6.18.57**; the archive shipped 6.18.50 at the time. `out/SOURCE` records it.+ kernel **6.18.57**; the archive shipped 6.18.50 at the time. The 0.8.1 rebuild (`-2+lordos`, BPF+ LSM and BTF) uses the same commit. `out/SOURCE` records it.- **Config:** `bcm2712_defconfig` (Pi 5, 16K pages) or `bcm2711_defconfig` (Pi 4, 4K pages), then`scripts/config` and `olddefconfig`. The whole diff against the defconfig (`out/config-*.diff`):@@ -129,17 +135,42 @@ tools/rpi/build-kernel.sh /var/tmp/lordos-kernel all # 2712 (Pi 5), v8 (Pi 4+CONFIG_SECURITY_LANDLOCK=y-CONFIG_LSM=""+CONFIG_LSM="landlock,lockdown,yama,integrity,bpf"+ -# CONFIG_SECURITY_YAMA is not set+ +CONFIG_SECURITY_YAMA=y+ -# CONFIG_BPF_LSM is not set+ +CONFIG_BPF_LSM=y+ -CONFIG_DEBUG_INFO_NONE=y+ +CONFIG_DEBUG_INFO=y+ +CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y+ +CONFIG_DEBUG_INFO_BTF=y+ +CONFIG_DEBUG_INFO_BTF_MODULES=y```- `CONFIG_LSM` uses the usual Debian order; the kernel skips the ones it doesn't build (lockdown,- Yama, IMA/EVM and the BPF LSM stay off, as Raspberry Pi has them), so the active list is- **`capability,landlock`**. The image's `cmdline.txt` has the same `lsm=` list.+ plus what `olddefconfig` derives from those (`PAHOLE_HAS_SPLIT_BTF`, `PROBE_EVENTS_BTF_ARGS`,+ `FUNCTION_TRACE_ARGS`, and a few new options answered "no").++ `CONFIG_LSM` uses the usual Debian order; the kernel skips the ones it doesn't build (lockdown+ and IMA/EVM stay off, as Raspberry Pi has them), so the active list is+ **`capability,landlock,yama,bpf`**. The image's `cmdline.txt` has the same `lsm=` list.+- **Yama (0.8.1)**, so the lordos package's `kernel.yama.ptrace_scope = 1` (a process may only+ trace its own descendants) applies on the Pi as on a PC; with 0.8.0's kernel the sysctl had+ nothing to set.+- **BPF LSM and BTF (0.8.1).** `CONFIG_BPF_LSM` lets `lord-netperm` attach its per-cgroup LSM+ program (`BPF_LSM_CGROUP`) to `socket_create`, so "No Bluetooth" is enforced for Linux apps on the+ Pi as on a PC; its attach point is the BTF id of `bpf_lsm_socket_create`, read from+ `/sys/kernel/btf/vmlinux` (`CONFIG_DEBUG_INFO_BTF`, generated by `pahole` from the DWARF debug+ info: Debian's `dwarves`). The debug info is only there to make BTF: the modules are stripped by+ the packaging (their `.BTF` sections stay) and the `-dbg` package isn't built+ (`DEB_BUILD_PROFILES=pkg.linux-lordos-rpi-<flavour>.nokerneldbg`), so the package hardly grows.+ The script checks `vmlinux` has a `.BTF` section. The build needs about 10 GB free while it runs+ (the object files carry DWARF) and takes about 50 % longer.- **Already in the defconfig, checked by the script** so a future defconfig can't drop them:`SECCOMP_FILTER` (sandbox.c), cgroup v2 with `MEMCG`, `CGROUP_PIDS` and `CGROUP_SCHED` (per-applimits; `cgroup_enable=memory` is in `cmdline.txt` because Raspberry Pi turns memcg off at boot),- and `BPF_SYSCALL`, `BPF_JIT`, `CGROUP_BPF` (lord-netperm's cgroup hooks). LordOS doesn't need user- namespaces (`USER_NS` stays as Raspberry Pi has it, on) or the BPF LSM.-- **Packages:** `make bindeb-pkg`, version `6.18.57-1+lordos`, release `6.18.57-lordos-rpi-2712`+ and `BPF_SYSCALL`, `BPF_JIT`, `CGROUP_BPF` (lord-netperm's cgroup hooks). `USER_NS` stays as+ Raspberry Pi has it, on (the launcher's own view for restricted Linux apps uses it).+- **Packages:** `make bindeb-pkg`, version `6.18.57-2+lordos` (`LORDOS_KREV`; `-1` was 0.8.0's,+ without the BPF LSM), release `6.18.57-lordos-rpi-2712`(`-lordos-rpi-v8` for the Pi 4). The `-rpi-<flavour>` suffix is what `raspi-firmware`'s hook keyson, so it installs exactly like Raspberry Pi's: `kernel_2712.img`, initramfs, device trees andoverlays in `/boot/firmware`. The script checks the package carries the device trees and@@ -351,6 +382,56 @@ Checked on the image (read-only, loop-mounted on the Pi): `config.txt`, `cmdlinetheme and `lsinitramfs` of both initramfs files. Still to check on a board: the timing of the firstframe of the splash after power-on, the hand-off with no flash on vc4, and 4K.+### Bluetooth++The Pi 5's Bluetooth is the second half of its CYW43455 (Wi-Fi is the first, on SDIO), wired to a+UART of the BCM2712. On the Pi 5 the kernel brings it up by itself, with no `hciattach` and none of+Raspberry Pi OS's `pi-bluetooth` scripts:++- **The device tree** (`bcm2712-rpi-5-b.dtb`) has a `brcm,bcm43438-bt` node under the UART, so the+ serial-device bus binds `hci_uart` with its BCM protocol (`CONFIG_BT_HCIUART_SERDEV`,+ `CONFIG_BT_HCIUART_BCM`, both in Raspberry Pi's defconfig and so in the LordOS kernel). It also+ carries `shutdown-gpios` (power), `max-speed` and `local-bd-address`, which the board firmware+ fills in with the board's own address before the kernel starts.+- **`btbcm`** loads the chip's patch: it looks for+ `brcm/BCM4345C0.raspberrypi,5-model-b.hcd` and then `brcm/BCM4345C0.hcd`. The image takes it from+ **Debian's `bluez-firmware`** (`non-free-firmware`, the same 63,806-byte file as Raspberry Pi's+ `+rpt` package, which only adds per-model symlinks), so the generic name is the one used. The+ chip reports the placeholder address `43:45:c0:00:1f:ac`; the kernel replaces it with the device+ tree's.+- **BlueZ** (Debian's `bluez`, `bluetooth.service` enabled) and the rest of the desktop side are the+ same as on a PC (`SETTINGS.md`, "Bluetooth"): our own D-Bus client in `lord-server`, the+ system-drawn pairing prompts, and headsets in PipeWire through `libspa-0.2-bluetooth` with the+ lordos package's WirePlumber drop-in (`lordos-bluez.conf`).+- **SCO routing, our helper.** Call audio (HFP/HSP: a headset's microphone) can leave the chip over+ HCI or over its PCM pins, which the Pi doesn't wire. Raspberry Pi OS's `bthelper` sets HCI with a+ vendor command of the chip; LordOS does the same with its own `/usr/lib/lordos/rpi/bt-uart`, run by+ `[email protected]` (udev starts it for an `hciN` whose parent is on the serial bus,+ `/etc/udev/rules.d/90-lordos-rpi-bt.rules`; before `bluetooth.service`). It reads the setting+ back first (`Read_SCO_PCM_Int_Param`, 0xfc1d) and only writes (`Write_SCO_PCM_Int_Param`,+ 0xfc1c, `01 02 00 01 01`: routing over HCI, with the same other parameters as `bthelper`) when it+ differs,+ leaves the controller powered as it found it, skips a controller blocked by rfkill or not on a+ UART, warns if the address is still the chip's placeholder, and never fails the boot. It uses+ `hciconfig`/`hcitool` from Debian's `bluez`; `lord-server` still never runs either (it speaks+ D-Bus to `bluetoothd` only). The setting survives a power cycle of the controller from Settings+ (an HCI reset): checked on the board.+- **Not used from Raspberry Pi OS:** `pi-bluetooth` (`hciuart.service`/`btuart` are for the older+ boards' `hciattach` and exit at once when the kernel already drives the chip; `bthelper` is+ replaced by the helper above, without its "power off and on again after 5 s" workaround, which+ the kernel driver doesn't need: Secure Simple Pairing is on from the start).++To turn Bluetooth off for good, `dtoverlay=disable-bt` in `config.txt` (the UART is then free); the+switch in Settings → Bluetooth only powers the controller off.++**Checked on a Pi 5 (2026-10-18, LordOS kernel `6.18.57-2+lordos`):** `hci0` on the UART with the+board's own address (`88:A2:…`, not the chip's placeholder), `bluetoothctl show` powered, and a+12-second scan lists the devices around it (4 to 5 in that room). "No Bluetooth" for a Linux app:+in the app's scope `socket(AF_BLUETOOTH)` gets `EPERM`, outside it works (`FIREWALL.md`, "Bluetooth+sockets"). **Not checked yet:** pairing and a headset's audio on the board (they need a device in+pairing mode next to it), and Settings → Bluetooth on the board's own screen (no LordOS session was+open; it is the same page and the same D-Bus client as on a PC, `SETTINGS.md`).+### After flashing`tools/rpi/verify-board.sh` (in the image as `/usr/lib/lordos/rpi/verify-board`) checks a freshly@@ -366,10 +447,12 @@ sudo /usr/lib/lordos/rpi/verify-board --repo ~/LordOS # plus make -C server tes|---|---|| kernel | `uname -r` is a `-lordos-rpi-*` kernel; page size 16K on the Pi 5 (4K with `-rpi-v8`) || Landlock | `/sys/kernel/security/lsm` lists `landlock`; the kernel log says `landlock: Up and running`; the kernel config has `SECURITY_LANDLOCK`, `SECCOMP_FILTER`, `CGROUP_BPF`, `BPF_SYSCALL`, `MEMCG` |+| BPF LSM, BTF | `bpf` in `/sys/kernel/security/lsm`; `/sys/kernel/btf/vmlinux` present; the kernel config has `BPF_LSM` and `DEBUG_INFO_BTF`; `lord-netperm` active || seccomp, cgroups | seccomp available; the cgroup v2 `memory` controller is on (`cgroup_enable=memory`) || first boot | the root partition has grown; no switch file left on `bootfs` (WARN for a `remote-desktop` still waiting for an account); not in setup mode || display, GPU | a `connected` KMS output with its mode (WARN with no monitor); `eglinfo -p gbm` shows V3D; the session log shows `GPU composition` || fan, temperature | a fan hwmon (`pwmfan`, rpm and PWM; `lord-fand` active if it's installed); SoC < 75 °C; `throttled=0x0` |+| Bluetooth | an `hciN` on the UART (with the patch file from the kernel log); `bluetoothd` active; `lordos-rpi-bt@hciN` active (WARN otherwise); the board's own address, not the chip's placeholder `43:45:c0:…` || remote desktop | port 5673 (or the configured one) listens **only** when `/etc/lordos/remote/config` has `enabled=1` || services | `lordos.service` active; SSH shown as on or off || `--repo` | `make -C server test-full` passes; `doc_evil.sh` N/N (25/25 with the archive tools installed); the three `sandbox-test` runs ok |diff --git a/tools/rpi/build-img.sh b/tools/rpi/build-img.shindex 77b8e64..157c627 100755--- a/tools/rpi/build-img.sh+++ b/tools/rpi/build-img.sh@@ -18,8 +18,9 @@# the Raspberry Pi archive key fingerprint; not recommended), KERNEL_DEBS (folder with the LordOS# kernel packages from tools/rpi/build-kernel.sh, default /var/tmp/lordos-kernel/out).#-# Kernel: the LordOS build of the Raspberry Pi kernel (with Landlock) when its .debs are in-# $KERNEL_DEBS; otherwise Raspberry Pi's archive kernel, which has no Landlock (a loud warning).+# Kernel: the LordOS build of the Raspberry Pi kernel (with Landlock, the BPF LSM and BTF) when its+# .debs are in $KERNEL_DEBS; otherwise Raspberry Pi's archive kernel, which has none of them (a loud+# warning).set -eu[ "$(id -u)" = 0 ] || { echo "build-img.sh: run as root (sudo)" >&2; exit 1; }@@ -68,8 +69,13 @@ PKGS_LORDOS="libwayland-server0 libxkbcommon0 xkb-data pipewire pipewire-pulse palsa-ucm-conf wpasupplicant openvpn fonts-noto-core fonts-noto-cjk fonts-noto-color-emoji libthai-dataskkdic rime-data-pinyin-simp fonts-dejavu-core"# Raspberry Pi: boot firmware (start*.elf are not used on the Pi 5: its firmware lives in the-# EEPROM) and Wi-Fi/BT (CYW43455); kernels below+# EEPROM) and Wi-Fi (CYW43455, firmware-brcm80211); kernels belowPKGS_RPI="raspi-firmware firmware-brcm80211 rsync"+# Bluetooth (the CYW43455 on a UART, brought up by the kernel; see docs/RASPBERRY.md, "Bluetooth"),+# all from Debian: BlueZ (bluetoothd, plus hciconfig/hcitool for rpi/bt-uart), the chip's patch+# (bluez-firmware: brcm/BCM4345C0.hcd), headset audio in PipeWire (libspa-0.2-bluetooth, with the+# lordos package's WirePlumber drop-in) and rfkill. The same BlueZ packages as the ISO.+PKGS_BT="bluez bluez-firmware libspa-0.2-bluetooth rfkill"PKGS_RPI_EXTRA="rpi-eeprom raspi-utils"# Kernels: Pi 5 (2712: 16K pages) and Pi 4/400/CM4 (v8: 4K pages). Ours (Landlock) if built,# per flavour; otherwise Raspberry Pi's.@@ -96,7 +102,8 @@ kernel_warning() {echo "##########################################################################################" >&2echo "## WARNING: no LordOS kernel for rpi-$1 in $KERNEL_DEBS: using Raspberry Pi's archive kernel." >&2echo "## It has NO Landlock: app and helper isolation will be seccomp-only on that board and" >&2- echo "## doc_evil.sh / sandbox-test fail. Build it first: tools/rpi/build-kernel.sh (docs/RASPBERRY.md)." >&2+ echo "## doc_evil.sh / sandbox-test fail; and no BPF LSM or BTF: \"No Bluetooth\" for Linux apps" >&2+ echo "## isn't enforced. Build it first: tools/rpi/build-kernel.sh (docs/RASPBERRY.md)." >&2echo "##########################################################################################" >&2}for fl in 2712 v8; do@@ -229,7 +236,7 @@ mount_ch "$CH"echo "== paquetes"in_root "$CH" apt-get update -q > "$WORK/apt.log" 2>&1 || { tail -30 "$WORK/apt.log"; exit 1; }# shellcheck disable=SC2086-in_root "$CH" apt-get install -y -q --no-install-recommends $PKGS_BASE $PKGS_LORDOS $PKGS_RPI $ARCHIVE_K $PKGS_GPU $PKGS_APPS $PKGS_SSH $PKGS_SPLASH \+in_root "$CH" apt-get install -y -q --no-install-recommends $PKGS_BASE $PKGS_LORDOS $PKGS_RPI $PKGS_BT $ARCHIVE_K $PKGS_GPU $PKGS_APPS $PKGS_SSH $PKGS_SPLASH \>> "$WORK/apt.log" 2>&1 || { tail -30 "$WORK/apt.log"; exit 1; }# the LordOS kernels (same hooks as Raspberry Pi's: initramfs, raspi-firmware copies kernel_2712.img,# device trees and overlays), and an apt pin so the archive kernel of that flavour never replaces them@@ -241,7 +248,7 @@ if [ -n "$OWN_KDEBS" ]; thentail -30 "$WORK/apt.log"; exit 1; }rm -rf "$CH/tmp/kernel"{- echo "# LordOS on Raspberry Pi: the kernel is LordOS's build of the Raspberry Pi kernel (with Landlock,"+ echo "# LordOS on Raspberry Pi: the kernel is LordOS's build of the Raspberry Pi kernel (Landlock, BPF LSM,"echo "# tools/rpi/build-kernel.sh, docs/RASPBERRY.md). Raspberry Pi's kernel packages for the same"echo "# board are never installed over it; LordOS updates ship as new linux-image-*-lordos-rpi-* packages."for fl in $OWN_FLAVOURS; do@@ -293,6 +300,10 @@ install -m 755 "$RPI/usr/lib/lordos/rpi/firstboot" "$RPI/usr/lib/lordos/rpi/waitinstall -m 755 "$ROOT/tools/rpi/verify-board.sh" "$CH/usr/lib/lordos/rpi/verify-board"install -m 644 "$RPI/etc/systemd/system/lordos-rpi-firstboot.service" "$CH/etc/systemd/system/"install -m 644 "$RPI/etc/systemd/system/lordos.service.d/rpi.conf" "$CH/etc/systemd/system/lordos.service.d/"+# the on-board Bluetooth: SCO routing helper, started by udev for the UART controller (docs/RASPBERRY.md)+install -m 755 "$RPI/usr/lib/lordos/rpi/bt-uart" "$CH/usr/lib/lordos/rpi/"+install -m 644 "$RPI/etc/systemd/system/[email protected]" "$CH/etc/systemd/system/"+install -D -m 644 "$RPI/etc/udev/rules.d/90-lordos-rpi-bt.rules" "$CH/etc/udev/rules.d/90-lordos-rpi-bt.rules"mkdir -p "$CH/var/lib/lordos/rpi": > "$CH/var/lib/lordos/rpi/resize-pending": > "$CH/var/lib/lordos/rpi/firstboot-pending"@@ -300,6 +311,7 @@ in_root "$CH" systemctl enable lordos-rpi-firstboot.service lordos.service > /dein_root "$CH" systemctl enable lord-fand.service > /dev/null # fans by temperature from the first boot (docs/FANS.md)# per-app network permissions and the device restrictions in the kernel (docs/FIREWALL.md), as on the ISOin_root "$CH" systemctl enable lord-netperm.service > /dev/null+in_root "$CH" systemctl enable bluetooth.service > /dev/null # bluez's postinst does it too; made surein_root "$CH" systemctl mask [email protected] > /dev/nullin_root "$CH" systemctl mask systemd-networkd-wait-online.service > /dev/null 2>&1 || true# no root password: the emergency console stays locked (like the installed system)@@ -312,6 +324,9 @@ KV8=$(ls "$CH/boot" | sed -n 's/^vmlinuz-\(.*-rpi-v8\)$/\1/p' | sort -V | tail -for kv in $KV2712 $KV8; doif grep -q '^CONFIG_SECURITY_LANDLOCK=y' "$CH/boot/config-$kv" 2>/dev/null; then echo " kernel $kv: Landlock built in"else echo " WARNING: kernel $kv has NO Landlock (seccomp-only isolation on that board)" >&2; fi+ if grep -q '^CONFIG_BPF_LSM=y' "$CH/boot/config-$kv" 2>/dev/null && grep -q '^CONFIG_DEBUG_INFO_BTF=y' "$CH/boot/config-$kv"; then+ echo " kernel $kv: BPF LSM and BTF built in"+ else echo " WARNING: kernel $kv has no BPF LSM/BTF (\"No Bluetooth\" for Linux apps not enforced on that board)" >&2; fidone# boot splash: the LordOS theme, and vc4 (HDMI) with DRM in the initramfs so Plymouth draws from the# first seconds instead of waiting for the root file system. Plymouth's own hook adds the rest of@@ -391,8 +406,9 @@ EOF# The boot splash: quiet splash (Plymouth), no serial console for it, no kernel logo or blinking cursor;# the console is tty1, where Plymouth draws and where Esc shows the boot messages. Removing "splash"# boots in text as before (docs/RASPBERRY.md, "Boot splash").-# lsm=: the same list as the LordOS kernel's CONFIG_LSM (Landlock for app isolation, server/src/sec);-# those the kernel lacks are ignored, so the active list is "capability,landlock".+# lsm=: the same list as the LordOS kernel's CONFIG_LSM (Landlock for app isolation, server/src/sec;+# Yama for ptrace_scope; bpf for lord-netperm's "No Bluetooth" program); those the kernel lacks are+# ignored, so the active list is "capability,landlock,yama,bpf".printf 'console=serial0,115200 console=tty1 root=PARTUUID=%s rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles logo.nologo vt.global_cursor_default=0 loglevel=3 cgroup_enable=memory lsm=landlock,lockdown,yama,integrity,bpf lordos.lang=en\n' \"$PARTUUID_ROOT" > "$WORK/mnt/boot/firmware/cmdline.txt"syncdiff --git a/tools/rpi/rootfs/etc/systemd/system/[email protected] b/tools/rpi/rootfs/etc/systemd/system/[email protected]new file mode 100644index 0000000..f0ed4ee--- /dev/null+++ b/tools/rpi/rootfs/etc/systemd/system/[email protected]@@ -0,0 +1,14 @@+[Unit]+Description=LordOS on Raspberry Pi: on-board Bluetooth (%I) SCO routing+Documentation=file:///usr/share/doc/lordos/README.md+# started by udev (90-lordos-rpi-bt.rules) when a UART Bluetooth controller appears; before+# bluetoothd, which then powers the controller as the user left it in Settings+Before=bluetooth.service+After=sys-subsystem-bluetooth-devices-%i.device+BindsTo=sys-subsystem-bluetooth-devices-%i.device+ConditionPathExists=/usr/lib/lordos/rpi/bt-uart++[Service]+Type=oneshot+ExecStart=/usr/lib/lordos/rpi/bt-uart %I+RemainAfterExit=yesdiff --git a/tools/rpi/rootfs/etc/udev/rules.d/90-lordos-rpi-bt.rules b/tools/rpi/rootfs/etc/udev/rules.d/90-lordos-rpi-bt.rulesnew file mode 100644index 0000000..170df66--- /dev/null+++ b/tools/rpi/rootfs/etc/udev/rules.d/90-lordos-rpi-bt.rules@@ -0,0 +1,4 @@+# LordOS on Raspberry Pi: the on-board Bluetooth controller (a serdev child of a UART) gets its+# SCO routing from /usr/lib/lordos/rpi/bt-uart ([email protected]). See docs/RASPBERRY.md.+ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci[0-9]*", ENV{DEVTYPE}=="host", SUBSYSTEMS=="serial", \+ TAG+="systemd", ENV{SYSTEMD_WANTS}+="lordos-rpi-bt@%k.service"diff --git a/tools/rpi/rootfs/usr/lib/lordos/rpi/bt-uart b/tools/rpi/rootfs/usr/lib/lordos/rpi/bt-uartnew file mode 100755index 0000000..f64b171--- /dev/null+++ b/tools/rpi/rootfs/usr/lib/lordos/rpi/bt-uart@@ -0,0 +1,48 @@+#!/bin/sh+# bt-uart — the Raspberry Pi 5's on-board Bluetooth (CYW43455 on a UART). See docs/RASPBERRY.md,+# "Bluetooth".+#+# The kernel does the bring-up by itself: the device tree's serdev node binds hci_uart (BCM+# protocol), btbcm loads brcm/BCM4345C0.hcd (Debian's bluez-firmware) and the board address comes+# from the device tree (local-bd-address, filled in by the firmware). So unlike the older boards+# there is no hciattach here. What this helper adds, once per controller, is the one setting the+# kernel doesn't make: SCO (call audio, HFP/HSP headsets) routed over HCI instead of the chip's PCM+# pins, which the Pi doesn't wire, with the chip's vendor command Write_SCO_PCM_Int_Param (0xfc1c).+# It only writes when the read-back (0xfc1d) differs, leaves the controller powered as it found+# it, does nothing for a controller that isn't a UART one or is blocked by rfkill, and never fails+# the boot.+#+# Usage ([email protected], started by udev for hciN on the serial bus): bt-uart hciN+PATH=/usr/sbin:/usr/bin:/sbin:/bin+dev=${1:-}+case "$dev" in hci[0-9]|hci[0-9][0-9]) ;; *) echo "bt-uart: usage: bt-uart hciN" >&2; exit 0 ;; esac+[ -d "/sys/class/bluetooth/$dev" ] || exit 0+command -v hciconfig > /dev/null && command -v hcitool > /dev/null || {+ echo "bt-uart: hciconfig/hcitool missing (package bluez)" >&2; exit 0; }+if command -v rfkill > /dev/null && rfkill -nro DEVICE,SOFT list 2>/dev/null | grep -q "^$dev blocked"; then+ echo "bt-uart: $dev is blocked by rfkill; nothing to do"; exit 0+fi+info=$(hciconfig "$dev" 2>/dev/null) || exit 0+echo "$info" | grep -q 'Bus: UART' || { echo "bt-uart: $dev is not a UART controller"; exit 0; }+raised=0+if ! echo "$info" | grep -q 'UP RUNNING'; then+ hciconfig "$dev" up 2>/dev/null || { echo "bt-uart: could not bring $dev up" >&2; exit 0; }+ raised=1+fi+addr=$(hciconfig "$dev" | sed -n 's/.*BD Address: \([0-9A-F:]*\).*/\1/p')+case "$addr" in+ 43:45:C0:*|43:43:A1:*|AA:AA:AA:AA:AA:AA|00:00:00:00:00:00)+ echo "bt-uart: $dev still has the chip's default address $addr (no local-bd-address in the device tree?)" >&2 ;;+esac+# the reply's parameters after the status byte: routing, rate, frame type, sync mode, clock mode+want="01 02 00 01 01"+cur=$(hcitool -i "$dev" cmd 0x3f 0x1d 2>/dev/null | sed -n 's/^ *01 1D FC 00 \(.*[0-9A-F]\) *$/\1/p')+if [ "$cur" = "$want" ]; then+ echo "bt-uart: $dev ($addr): SCO already routed over HCI"+elif hcitool -i "$dev" cmd 0x3f 0x1c 0x01 0x02 0x00 0x01 0x01 > /dev/null 2>&1; then+ echo "bt-uart: $dev ($addr): SCO routed over HCI (was: ${cur:-unknown})"+else+ echo "bt-uart: $dev ($addr): could not set the SCO routing (headset microphones may not work)" >&2+fi+[ "$raised" = 1 ] && hciconfig "$dev" down 2>/dev/null+exit 0diff --git a/tools/rpi/verify-board.sh b/tools/rpi/verify-board.shindex b009223..b754028 100644--- a/tools/rpi/verify-board.sh+++ b/tools/rpi/verify-board.sh@@ -49,17 +49,26 @@ case ",$LSM," in*,landlock,*) row PASS "Landlock in the LSM list" "$LSM" ;;*) row FAIL "Landlock in the LSM list" "/sys/kernel/security/lsm = '${LSM:-unreadable}'" ;;esac-KLOG=$( (dmesg 2>/dev/null || journalctl -k -b --no-pager 2>/dev/null) | grep -i 'landlock' | head -1)+# the bpf LSM and BTF: lord-netperm's "No Bluetooth" program for Linux apps (docs/FIREWALL.md)+case ",$LSM," in+ *,bpf,*) row PASS "BPF LSM in the LSM list" "$LSM" ;;+ *) row FAIL "BPF LSM in the LSM list" "no bpf in '${LSM:-unreadable}' (\"No Bluetooth\" not enforced)" ;;+esac+if [ -s /sys/kernel/btf/vmlinux ]; then row PASS "kernel BTF" "/sys/kernel/btf/vmlinux, $(($(stat -c %s /sys/kernel/btf/vmlinux) / 1024)) KiB"+else row FAIL "kernel BTF" "no /sys/kernel/btf/vmlinux (lord-netperm can't attach its LSM program)"; fi+if systemctl is-active -q lord-netperm.service 2>/dev/null; then row PASS "lord-netperm" "active"+elif systemctl cat lord-netperm.service >/dev/null 2>&1; then row FAIL "lord-netperm" "$(systemctl is-active lord-netperm.service)"; fi+KLOG=$( (dmesg 2>/dev/null || journalctl -k -b --no-pager 2>/dev/null) | grep -i 'landlock:' | head -1)if echo "$KLOG" | grep -qi 'up and running'; then row PASS "Landlock initialized" "$(echo "$KLOG" | sed 's/^.*\] //')"elif [ -z "$KLOG" ]; then row WARN "Landlock initialized" "no landlock line in the kernel log$([ "$(id -u)" = 0 ] || echo " (run as root)")"else row FAIL "Landlock initialized" "$KLOG"; fiCFG=/boot/config-$KRELif [ -f "$CFG" ]; thenMISS=""- for o in SECURITY_LANDLOCK SECCOMP_FILTER CGROUP_BPF BPF_SYSCALL MEMCG; do+ for o in SECURITY_LANDLOCK SECCOMP_FILTER CGROUP_BPF BPF_SYSCALL BPF_LSM DEBUG_INFO_BTF MEMCG; dogrep -q "^CONFIG_$o=y" "$CFG" || MISS="$MISS $o"done- if [ -z "$MISS" ]; then row PASS "kernel config" "LANDLOCK SECCOMP_FILTER CGROUP_BPF BPF_SYSCALL MEMCG"+ if [ -z "$MISS" ]; then row PASS "kernel config" "LANDLOCK SECCOMP_FILTER CGROUP_BPF BPF_SYSCALL BPF_LSM DEBUG_INFO_BTF MEMCG"else row FAIL "kernel config" "missing:$MISS"; fifigrep -q '^Seccomp:' /proc/self/status && row PASS "seccomp" "available" || row FAIL "seccomp" "no Seccomp field in /proc/self/status"@@ -135,6 +144,27 @@ if command -v vcgencmd >/dev/null; thenelse row WARN "throttling" "throttled=$TH (under-voltage or heat; 0x50000 = happened before)"; fifi+# ---- Bluetooth: the on-board CYW43455 on its UART (docs/RASPBERRY.md, "Bluetooth") ----+HCI=""+for h in /sys/class/bluetooth/hci*; do+ [ -e "$h" ] || continue+ case "$(readlink -f "$h")" in */serial*/bluetooth/*) HCI=$(basename "$h") ;; esac+done+if [ -n "$HCI" ]; then+ FW=$( (dmesg 2>/dev/null || journalctl -k -b --no-pager 2>/dev/null) | grep -m1 "$HCI: BCM.*hcd" | sed 's/^.*\] //')+ row PASS "Bluetooth controller" "$HCI on the UART${FW:+ ($FW)}"+ if systemctl is-active -q bluetooth.service; then row PASS "bluetoothd" "active"+ else row FAIL "bluetoothd" "$(systemctl is-active bluetooth.service)"; fi+ if systemctl is-active -q "lordos-rpi-bt@$HCI.service"; then row PASS "Bluetooth UART helper" "lordos-rpi-bt@$HCI: $(journalctl -b -u "lordos-rpi-bt@$HCI" -o cat --no-pager 2>/dev/null | grep -m1 'bt-uart:' | sed 's/^bt-uart: //')"+ else row WARN "Bluetooth UART helper" "lordos-rpi-bt@$HCI is $(systemctl is-active "lordos-rpi-bt@$HCI.service")"; fi+ if command -v btmgmt > /dev/null; then+ A=$(btmgmt --index "${HCI#hci}" info 2>/dev/null | sed -n 's/^[[:space:]]*addr \([0-9A-F:]*\).*/\1/p' | head -1)+ case "$A" in ""|43:45:C0:*|AA:AA:AA:AA:AA:AA|00:00:00:00:00:00) row FAIL "Bluetooth address" "'${A}' (the chip's default: no local-bd-address)" ;;+ *) row PASS "Bluetooth address" "$A" ;; esac+ fi+elif [ -e /proc/device-tree/aliases/bluetooth ]; then row FAIL "Bluetooth controller" "the device tree has one but no hciN on a UART (dtoverlay=disable-bt? hci_uart?)"+else row INFO "Bluetooth controller" "none on this board"; fi+# ---- remote desktop: listening on its port only when enabled ----RC=/etc/lordos/remote/configEN=0; PORT=5673