From 4ce7bd285946c30253753befb4c4e7713000932e Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sun, 22 Nov 2026 04:29:22 -0500 Subject: [PATCH 1/3] Tuned kernels keep firewall, container, VM and VPN support (2.6.1) Tuned's localmodconfig drops every module that is not loaded while configuring, and firewall rules, Docker, libvirt and VPNs load theirs only when they run. The 7.3.5 Tuned kernel had lost them all: libvirt's default NAT network could not start (no REJECT target), and Docker ran only on what happened to be loaded. missing_required now also covers, whenever NETFILTER is on, the options Docker's check-config.sh, libvirt, ufw/firewalld, WireGuard, OpenVPN, Tailscale and IPsec need (REQUIRED_NETWORK_SYMBOLS as modules, REQUIRED_NETWORK_FLAGS switched on). They are turned on before configuring, again after localmodconfig, and the build refuses to start without them. A live test configures a real tree in Tuned mode on this machine and checks every required option is on. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 9 + Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 3 +- data/io.github.labj1987.KernelPop.appdata.xml | 1 + docs/SOURCE_BUILD.md | 23 +- src/build.rs | 216 ++++++++++++++++-- 7 files changed, 236 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 650fe95..071c3fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ One `## — ` heading per released version, newest first. A rele carries its section as written, and the AppStream `` list is generated from these headings. +## 2.6.1 — 2026-11-22 + +- **Tuned kernels keep firewall, container, VM and VPN support.** Tuned for this machine drops + modules that are not loaded while you configure, and firewall rules, Docker, VM networks and + VPNs load theirs only when they run. A Tuned kernel could therefore not start libvirt's default + network (no REJECT target), and Docker or a VPN could fail on a rule nothing had loaded before. + Every mode now keeps the networking options Docker, libvirt, ufw/firewalld, WireGuard, OpenVPN, + Tailscale and IPsec need, and Kernel Pop refuses to build a kernel without them. + ## 2.6.0 — 2026-11-18 - **A kernel that could not be signed under Secure Boot no longer leaves a broken boot entry.** On diff --git a/Cargo.lock b/Cargo.lock index 0843750..80cee92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3386,7 +3386,7 @@ dependencies = [ [[package]] name = "kernel-pop" -version = "2.6.0" +version = "2.6.1" dependencies = [ "anyhow", "ashpd", diff --git a/Cargo.toml b/Cargo.toml index 9643327..da7efd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kernel-pop" -version = "2.6.0" +version = "2.6.1" edition = "2021" rust-version = "1.100" description = "Kernel Pop — GUI that builds kernel.org kernels for this machine and installs them" diff --git a/README.md b/README.md index 1579b2d..97ff24e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ VFS-panics on boot. This app is built around not letting that happen: the hardware in this computer plus the kinds people plug in, such as USB storage, USB and Bluetooth controllers, keyboards and mice, headsets, webcams, docks and VPN/container - networking; about a third of the build time) and **Use my own .config**. The fixes every + networking; about a third of the build time; every mode keeps what game + controllers, firewalls, Docker, VMs and VPNs need) and **Use my own .config**. The fixes every Ubuntu config needs for a kernel.org tree are applied automatically, and a summary is shown before the build starts - Builds never run as root. Missing build tools are listed and installed diff --git a/data/io.github.labj1987.KernelPop.appdata.xml b/data/io.github.labj1987.KernelPop.appdata.xml index fad9f5b..e36462f 100644 --- a/data/io.github.labj1987.KernelPop.appdata.xml +++ b/data/io.github.labj1987.KernelPop.appdata.xml @@ -30,6 +30,7 @@ System + diff --git a/docs/SOURCE_BUILD.md b/docs/SOURCE_BUILD.md index 7e8f1b9..d61f0cc 100644 --- a/docs/SOURCE_BUILD.md +++ b/docs/SOURCE_BUILD.md @@ -160,9 +160,26 @@ Fixes applied in every mode with `scripts/config`, then `make olddefconfig`: the log and the summary say why. `olddefconfig` would drop it silently otherwise. - Debug info: see the measurement below. - -After configuring, the build refuses to start unless `LOCALVERSION` and the -two key settings came out as set. The summary also warns when an option the +- Required options (`build::missing_required`), turned on as modules (yes/no + options switched on) when the base config has them off, and in Tuned again + after localmodconfig, which drops every module that is not loaded: + - input: `USB_HID`, `HID_GENERIC`, `UHID`, `INPUT_UINPUT`, `INPUT_JOYDEV`, + and `BT_HIDP` with classic Bluetooth. Without `UHID` (the 7.3.4 Tuned + kernel) Bluetooth controllers, keyboards and mice connect but never become + input devices. + - networking, whenever `NETFILTER` is on: nftables and iptables with NAT, + masquerade, mangle, raw and the REJECT targets, conntrack helpers, the + common x_tables matches, ipset and IPVS, bridge netfilter and VLAN + filtering, veth/macvlan/ipvlan/vxlan, overlayfs, vhost-net and vsock, TUN, + WireGuard and IPsec (`build::REQUIRED_NETWORK_SYMBOLS` and + `REQUIRED_NETWORK_FLAGS`; the list follows Docker's `check-config.sh`, + libvirt's NAT network, ufw/firewalld and the common VPNs). These modules + load only when a firewall rule, container or VPN uses them, so the 7.3.5 + Tuned kernel had lost them all: libvirt's default network could not start + (no `REJECT`), and Docker ran only on what happened to be loaded. + +After configuring, the build refuses to start unless `LOCALVERSION`, the +two key settings and every required option came out as set. The summary also warns when an option the kernel needs to trust MOK-signed modules is off (below), and when `make kernelrelease` differs from `-kernelpop` (a tree with its own localversion file). diff --git a/src/build.rs b/src/build.rs index c810746..936c813 100644 --- a/src/build.rs +++ b/src/build.rs @@ -481,19 +481,153 @@ pub fn config_value(config: &str, name: &str) -> Option { pub const REQUIRED_INPUT_SYMBOLS: &[&str] = &["USB_HID", "HID_GENERIC", "UHID", "INPUT_UINPUT", "INPUT_JOYDEV"]; /// The same for kernels with classic Bluetooth (BT_BREDR): Bluetooth HID. pub const REQUIRED_BLUETOOTH_SYMBOLS: &[&str] = &["BT_HIDP"]; +/// Options every kernel with netfilter must have as modules (or built in): firewalls (nftables, +/// iptables, ufw, firewalld), NAT, Docker and Podman networking (Docker's check-config list), +/// libvirt's NAT network, VPNs (WireGuard, OpenVPN, Tailscale, IPsec) and VM networking. They +/// are only loaded when used, so Tuned's localmodconfig used to drop them: libvirt's default +/// network could not start without the REJECT targets. +pub const REQUIRED_NETWORK_SYMBOLS: &[&str] = &[ + // nftables + "NF_TABLES", + "NFT_CT", + "NFT_NAT", + "NFT_MASQ", + "NFT_REDIR", + "NFT_REJECT", + "NFT_REJECT_INET", + "NFT_COMPAT", + "NFT_LIMIT", + "NFT_LOG", + "NFT_NUMGEN", + "NFT_QUOTA", + "NFT_FIB_INET", + "NFT_FIB_IPV4", + "NFT_FIB_IPV6", + "NFT_FWD_NETDEV", + // connection tracking, NAT and REJECT + "NF_CONNTRACK", + "NF_NAT", + "NF_REJECT_IPV4", + "NF_REJECT_IPV6", + "NF_CONNTRACK_FTP", + "NF_NAT_FTP", + "NF_CONNTRACK_TFTP", + "NF_NAT_TFTP", + // x_tables matches and targets (iptables, iptables-nft, ufw, Docker) + "NETFILTER_XTABLES", + "NETFILTER_XT_MATCH_ADDRTYPE", + "NETFILTER_XT_MATCH_CONNTRACK", + "NETFILTER_XT_MATCH_IPVS", + "NETFILTER_XT_MARK", + "NETFILTER_XT_CONNMARK", + "NETFILTER_XT_MATCH_COMMENT", + "NETFILTER_XT_MATCH_LIMIT", + "NETFILTER_XT_MATCH_MULTIPORT", + "NETFILTER_XT_MATCH_RECENT", + "NETFILTER_XT_MATCH_OWNER", + "NETFILTER_XT_MATCH_STATE", + "NETFILTER_XT_TARGET_LOG", + "NETFILTER_XT_TARGET_TCPMSS", + "NETFILTER_XT_TARGET_CHECKSUM", + "NETFILTER_XT_TARGET_MASQUERADE", + "NETFILTER_XT_TARGET_REDIRECT", + // iptables tables (IPv4 and IPv6) + "IP_NF_IPTABLES", + "IP_NF_FILTER", + "IP_NF_MANGLE", + "IP_NF_RAW", + "IP_NF_NAT", + "IP_NF_TARGET_REJECT", + "IP_NF_TARGET_MASQUERADE", + "IP_NF_TARGET_REDIRECT", + "IP6_NF_IPTABLES", + "IP6_NF_FILTER", + "IP6_NF_MANGLE", + "IP6_NF_RAW", + "IP6_NF_NAT", + "IP6_NF_TARGET_REJECT", + "IP6_NF_TARGET_MASQUERADE", + // ipset and IPVS (firewalld, Docker swarm, kube-proxy) + "IP_SET", + "IP_SET_HASH_IP", + "IP_SET_HASH_NET", + "IP_VS", + "IP_VS_RR", + // container and VM networking + "BRIDGE", + "BRIDGE_NETFILTER", + "VLAN_8021Q", + "VETH", + "MACVLAN", + "IPVLAN", + "VXLAN", + "DUMMY", + "OVERLAY_FS", + "NET_CLS_CGROUP", + "VHOST_NET", + "MACVTAP", + "VSOCKETS", + "VHOST_VSOCK", + // VPNs + "TUN", + "WIREGUARD", + "INET_ESP", + "INET6_ESP", + "XFRM_USER", +]; +/// The yes/no options the network modules above need (they cannot be modules). +pub const REQUIRED_NETWORK_FLAGS: &[&str] = &[ + "NETFILTER_ADVANCED", + "NF_TABLES_INET", + "NF_TABLES_IPV4", + "NF_TABLES_IPV6", + "NF_TABLES_NETDEV", + "BRIDGE_VLAN_FILTERING", + "IP_VS_PROTO_TCP", + "IP_VS_PROTO_UDP", + "IP_VS_NFCT", + "IP_VS_IPV6", + "POSIX_MQUEUE", +]; /// The required options `config` leaves off (neither y nor m). For Match -/// and Tuned these are turned on as modules before configuring, since -/// localmodconfig only ever removes modules. +/// and Tuned these are turned on before configuring, and for Tuned again +/// after localmodconfig, which removes every module that is not loaded. pub fn missing_required(config: &str) -> Vec<&'static str> { let on = |s: &str| matches!(config_value(config, s).as_deref(), Some("y" | "m")); let mut need: Vec<&'static str> = REQUIRED_INPUT_SYMBOLS.to_vec(); if on("BT") && on("BT_BREDR") { need.extend_from_slice(REQUIRED_BLUETOOTH_SYMBOLS); } + if on("NETFILTER") { + need.extend_from_slice(REQUIRED_NETWORK_FLAGS); + need.extend_from_slice(REQUIRED_NETWORK_SYMBOLS); + } need.into_iter().filter(|s| !on(s)).collect() } +/// scripts/config arguments that turn `symbols` on: yes/no options with +/// --enable, everything else as a module (a missing option is never =y, so +/// nothing built in is demoted). +pub fn enable_args<'a>(symbols: &[&'a str]) -> Vec<&'a str> { + symbols.iter().flat_map(|s| [if REQUIRED_NETWORK_FLAGS.contains(s) { "--enable" } else { "--module" }, *s]).collect() +} + +/// What needs `symbols`, for the configuration summary. +fn enable_users(symbols: &[&str]) -> &'static str { + let net = symbols.iter().any(|s| REQUIRED_NETWORK_SYMBOLS.contains(s) || REQUIRED_NETWORK_FLAGS.contains(s)); + let input = symbols.iter().any(|s| REQUIRED_INPUT_SYMBOLS.contains(s) || REQUIRED_BLUETOOTH_SYMBOLS.contains(s)); + match (input, net) { + (true, true) => "game controllers, Bluetooth input devices, firewalls, Docker, VMs or VPNs", + (false, true) => "firewalls, Docker and other containers, VM networks or VPNs", + _ => "game controllers or Bluetooth input devices", + } +} + +fn enable_what(symbols: &[&str]) -> String { + format!("for {}", enable_users(symbols)) +} + /// The number of =m symbols: how many modules the configuration builds. pub fn module_count(config: &str) -> usize { config.lines().filter(|l| l.starts_with("CONFIG_") && l.ends_with("=m")).count() @@ -778,24 +912,19 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> "SYSTEM_REVOCATION_KEYS set to \"\" (same reason)".to_string(), format!("Debug info {debug_text}"), ]; - let apply_fixes = || -> Result<()> { + let apply_fixes = |enable: &[&str]| -> Result<()> { let mut c = scripts_config(tree); c.args(["--set-str", "LOCALVERSION", LOCALVERSION]) .args(["--set-str", "SYSTEM_TRUSTED_KEYS", ""]) .args(["--set-str", "SYSTEM_REVOCATION_KEYS", ""]) - .args(&debug_args); - for sym in &enable { - c.args(["--module", sym]); - } + .args(&debug_args) + .args(enable_args(enable)); r.run(c, "scripts/config").map(|_| ()) }; if !enable.is_empty() { - fixes.push(format!( - "CONFIG_{} turned on as modules (game controllers and Bluetooth controllers, keyboards and mice need them)", - enable.join(", CONFIG_") - )); + fixes.push(format!("Turned on {}: CONFIG_{}", enable_what(&enable), enable.join(", CONFIG_"))); } - apply_fixes()?; + apply_fixes(&enable)?; let mut notes = vec![]; if base_rust { @@ -848,8 +977,13 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> let mut c = make(tree); c.arg(format!("LSMOD={}", list.display())).arg("localmodconfig"); r.run(c, "make localmodconfig")?; - apply_fixes()?; + // localmodconfig drops every module that is not loaded, required ones included: put them back. + let restore = missing_required(&std::fs::read_to_string(tree.join(".config"))?); + apply_fixes(&restore)?; olddefconfig()?; + if !restore.is_empty() { + fixes.push(format!("Kept after localmodconfig {}: {} options", enable_what(&restore), restore.len())); + } fixes.push(format!("localmodconfig: only drivers for {what}")); notes.push( "Tuned: hardware that is not present now and not a common plug-in kind (an unusual USB gadget, a different Wi-Fi card) may have no driver in this kernel; Match this system includes everything.".into(), @@ -866,7 +1000,7 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> expect("LOCALVERSION", &format!("\"{LOCALVERSION}\""))?; let missing = missing_required(&config); if !missing.is_empty() { - let what = format!("CONFIG_{} is off: game controllers or Bluetooth input devices would not work with this kernel", missing.join(", CONFIG_")); + let what = format!("CONFIG_{} is off: {} would not work with this kernel", missing.join(", CONFIG_"), enable_users(&missing)); if own_config { notes.push(format!("{what}.")); } else { @@ -1420,6 +1554,38 @@ mod tests { assert_eq!(missing_required(&base), ["UHID", "BT_HIDP"]); } + #[test] + fn firewall_container_and_vpn_options_always_kept() { + let mut full = + String::from("CONFIG_USB_HID=y\nCONFIG_HID_GENERIC=y\nCONFIG_UHID=m\nCONFIG_INPUT_UINPUT=m\nCONFIG_INPUT_JOYDEV=m\nCONFIG_NETFILTER=y\n"); + for s in REQUIRED_NETWORK_FLAGS { + full.push_str(&format!("CONFIG_{s}=y\n")); + } + for s in REQUIRED_NETWORK_SYMBOLS { + full.push_str(&format!("CONFIG_{s}=m\n")); + } + assert!(missing_required(&full).is_empty()); + // LordNikon's 7.3.5 Tuned kernel: no REJECT, so libvirt's NAT network could not start. + let no_reject = full + .replace("CONFIG_NFT_REJECT=m\n", "# CONFIG_NFT_REJECT is not set\n") + .replace("CONFIG_IP_NF_TARGET_REJECT=m\n", "") + .replace("CONFIG_BRIDGE_VLAN_FILTERING=y\n", ""); + assert_eq!(missing_required(&no_reject), ["BRIDGE_VLAN_FILTERING", "NFT_REJECT", "IP_NF_TARGET_REJECT"]); + // Yes/no options are switched on, the rest become modules. + assert_eq!(enable_args(&["BRIDGE_VLAN_FILTERING", "NFT_REJECT"]), ["--enable", "BRIDGE_VLAN_FILTERING", "--module", "NFT_REJECT"]); + // Without netfilter at all, none of them is asked for. + let no_netfilter = no_reject.replace("CONFIG_NETFILTER=y\n", ""); + assert!(missing_required(&no_netfilter).is_empty()); + // Every option is listed once, in one list, as a plain Kconfig name. + let mut seen = std::collections::HashSet::new(); + for s in REQUIRED_INPUT_SYMBOLS.iter().chain(REQUIRED_BLUETOOTH_SYMBOLS).chain(REQUIRED_NETWORK_FLAGS).chain(REQUIRED_NETWORK_SYMBOLS) { + assert!(s.chars().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_'), "{s}"); + assert!(seen.insert(*s), "{s} listed twice"); + } + assert_eq!(enable_users(&["UHID"]), "game controllers or Bluetooth input devices"); + assert_eq!(enable_users(&["NFT_REJECT"]), "firewalls, Docker and other containers, VM networks or VPNs"); + } + #[test] fn config_values() { let c = "CONFIG_RUST=y\nCONFIG_LOCALVERSION=\"-kernelpop\"\n# CONFIG_DEBUG_INFO_NONE is not set\nCONFIG_E1000=m\nCONFIG_EXT4_FS=y\nCONFIG_SND=m\n"; @@ -1659,6 +1825,28 @@ mod tests { assert!(!tree.exists()); } + /// Extract and configure only, in Tuned mode on this machine: every required option (input, + /// Bluetooth HID, firewall/container/VPN networking) must still be on after localmodconfig. + /// KERNEL_POP_LIVE_TARBALL=. + #[test] + #[ignore] + fn live_prepare_tuned_keeps_required_options() { + let path = PathBuf::from(std::env::var("KERNEL_POP_LIVE_TARBALL").expect("set KERNEL_POP_LIVE_TARBALL")); + let tarball = crate::source::inspect(&path).unwrap(); + let running = String::from_utf8(Command::new("uname").arg("-r").output().unwrap().stdout).unwrap().trim().to_string(); + let trust = SourceTrust::Unverified { reason: "test: configure only".into() }; + let req = BuildRequest { tarball, trust, mode: ConfigMode::TunedForMachine, running_kernel: running }; + let events: EventSink = Arc::new(|_| {}); + let p = prepare(req, events, BuildControl::new(), 300 << 20).unwrap(); + println!("{}", p.summary.text()); + let config = std::fs::read_to_string(p.tree.join(".config")).unwrap(); + assert!(missing_required(&config).is_empty(), "{:?}", missing_required(&config)); + for s in ["NFT_REJECT", "IP_NF_TARGET_REJECT", "IP_NF_TARGET_MASQUERADE", "NFT_MASQ", "BRIDGE_NETFILTER", "WIREGUARD", "UHID"] { + assert!(matches!(config_value(&config, s).as_deref(), Some("y" | "m")), "CONFIG_{s} is off"); + } + p.discard(); + } + /// A real build of a real kernel.org tarball, like the Build page does /// it: KERNEL_POP_LIVE_TARBALL= KERNEL_POP_LIVE_MODE=match|tuned, /// optionally KERNEL_POP_LIVE_UNVERIFIED=1 to skip the signature check. From 5115d9898add71cd443550c02bd3c04b51594efd Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sun, 22 Nov 2026 04:39:26 -0500 Subject: [PATCH 2/3] Review round 1: legacy iptables switch, ufw's hl/rt matches, only options the tree defines Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 5 ++- README.md | 2 +- docs/SOURCE_BUILD.md | 13 ++++-- src/build.rs | 99 ++++++++++++++++++++++++++++++++++++-------- 4 files changed, 95 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 071c3fa..67de2f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,9 @@ headings. modules that are not loaded while you configure, and firewall rules, Docker, VM networks and VPNs load theirs only when they run. A Tuned kernel could therefore not start libvirt's default network (no REJECT target), and Docker or a VPN could fail on a rule nothing had loaded before. - Every mode now keeps the networking options Docker, libvirt, ufw/firewalld, WireGuard, OpenVPN, - Tailscale and IPsec need, and Kernel Pop refuses to build a kernel without them. + Match this system and Tuned now keep the networking options Docker, libvirt, ufw/firewalld, + WireGuard, OpenVPN, Tailscale and IPsec need, and refuse to build a kernel without them; with your + own .config, the summary warns when one is off. ## 2.6.0 — 2026-11-18 diff --git a/README.md b/README.md index 97ff24e..dffc892 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ VFS-panics on boot. This app is built around not letting that happen: the hardware in this computer plus the kinds people plug in, such as USB storage, USB and Bluetooth controllers, keyboards and mice, headsets, webcams, docks and VPN/container - networking; about a third of the build time; every mode keeps what game + networking; about a third of the build time; both keep what game controllers, firewalls, Docker, VMs and VPNs need) and **Use my own .config**. The fixes every Ubuntu config needs for a kernel.org tree are applied automatically, and a summary is shown before the build starts diff --git a/docs/SOURCE_BUILD.md b/docs/SOURCE_BUILD.md index d61f0cc..0cef5eb 100644 --- a/docs/SOURCE_BUILD.md +++ b/docs/SOURCE_BUILD.md @@ -160,16 +160,21 @@ Fixes applied in every mode with `scripts/config`, then `make olddefconfig`: the log and the summary say why. `olddefconfig` would drop it silently otherwise. - Debug info: see the measurement below. -- Required options (`build::missing_required`), turned on as modules (yes/no +- Required options (`build::missing_required`; Match and Tuned only, Use my own + .config gets a warning in the summary instead), turned on as modules (yes/no options switched on) when the base config has them off, and in Tuned again - after localmodconfig, which drops every module that is not loaded: + after localmodconfig, which drops every module that is not loaded. Options + the tree's Kconfig does not define (an older longterm kernel, a renamed + option) are skipped: - input: `USB_HID`, `HID_GENERIC`, `UHID`, `INPUT_UINPUT`, `INPUT_JOYDEV`, and `BT_HIDP` with classic Bluetooth. Without `UHID` (the 7.3.4 Tuned kernel) Bluetooth controllers, keyboards and mice connect but never become input devices. - networking, whenever `NETFILTER` is on: nftables and iptables with NAT, masquerade, mangle, raw and the REJECT targets, conntrack helpers, the - common x_tables matches, ipset and IPVS, bridge netfilter and VLAN + common x_tables matches (with `hl` and the IPv6 `rt` match that ufw's + rules use, and the 6.17+ `NETFILTER_XTABLES_LEGACY` switch the iptables + tables depend on), ipset and IPVS, bridge netfilter and VLAN filtering, veth/macvlan/ipvlan/vxlan, overlayfs, vhost-net and vsock, TUN, WireGuard and IPsec (`build::REQUIRED_NETWORK_SYMBOLS` and `REQUIRED_NETWORK_FLAGS`; the list follows Docker's `check-config.sh`, @@ -179,7 +184,7 @@ Fixes applied in every mode with `scripts/config`, then `make olddefconfig`: (no `REJECT`), and Docker ran only on what happened to be loaded. After configuring, the build refuses to start unless `LOCALVERSION`, the -two key settings and every required option came out as set. The summary also warns when an option the +two key settings and (Match and Tuned) every required option came out as set. The summary also warns when an option the kernel needs to trust MOK-signed modules is off (below), and when `make kernelrelease` differs from `-kernelpop` (a tree with its own localversion file). diff --git a/src/build.rs b/src/build.rs index 936c813..9e075f1 100644 --- a/src/build.rs +++ b/src/build.rs @@ -522,6 +522,7 @@ pub const REQUIRED_NETWORK_SYMBOLS: &[&str] = &[ "NETFILTER_XT_CONNMARK", "NETFILTER_XT_MATCH_COMMENT", "NETFILTER_XT_MATCH_LIMIT", + "NETFILTER_XT_MATCH_HL", "NETFILTER_XT_MATCH_MULTIPORT", "NETFILTER_XT_MATCH_RECENT", "NETFILTER_XT_MATCH_OWNER", @@ -533,6 +534,7 @@ pub const REQUIRED_NETWORK_SYMBOLS: &[&str] = &[ "NETFILTER_XT_TARGET_REDIRECT", // iptables tables (IPv4 and IPv6) "IP_NF_IPTABLES", + "IP_NF_IPTABLES_LEGACY", "IP_NF_FILTER", "IP_NF_MANGLE", "IP_NF_RAW", @@ -541,6 +543,8 @@ pub const REQUIRED_NETWORK_SYMBOLS: &[&str] = &[ "IP_NF_TARGET_MASQUERADE", "IP_NF_TARGET_REDIRECT", "IP6_NF_IPTABLES", + "IP6_NF_IPTABLES_LEGACY", + "IP6_NF_MATCH_RT", "IP6_NF_FILTER", "IP6_NF_MANGLE", "IP6_NF_RAW", @@ -578,6 +582,7 @@ pub const REQUIRED_NETWORK_SYMBOLS: &[&str] = &[ /// The yes/no options the network modules above need (they cannot be modules). pub const REQUIRED_NETWORK_FLAGS: &[&str] = &[ "NETFILTER_ADVANCED", + "NETFILTER_XTABLES_LEGACY", "NF_TABLES_INET", "NF_TABLES_IPV4", "NF_TABLES_IPV6", @@ -613,6 +618,50 @@ pub fn enable_args<'a>(symbols: &[&'a str]) -> Vec<&'a str> { symbols.iter().flat_map(|s| [if REQUIRED_NETWORK_FLAGS.contains(s) { "--enable" } else { "--module" }, *s]).collect() } +/// `CONFIG_A, CONFIG_B` for a short list, a count for a long one (the names are in the log). +fn option_list(symbols: &[&str]) -> String { + if symbols.len() > 8 { + format!("{} options", symbols.len()) + } else { + format!("CONFIG_{}", symbols.join(", CONFIG_")) + } +} + +/// Every option the tree's Kconfig files define (`config X` / `menuconfig X`). +pub fn kconfig_symbols(tree: &Path) -> Result> { + let mut out = std::collections::HashSet::new(); + let mut stack = vec![tree.to_path_buf()]; + while let Some(dir) = stack.pop() { + for e in std::fs::read_dir(&dir).with_context(|| format!("Could not read {}", dir.display()))? { + let e = e?; + let path = e.path(); + let ft = e.file_type()?; + if ft.is_dir() { + stack.push(path); + } else if ft.is_file() && e.file_name().to_string_lossy().starts_with("Kconfig") { + out.extend(kconfig_text_symbols(&std::fs::read_to_string(&path).unwrap_or_default())); + } + } + } + Ok(out) +} + +fn kconfig_text_symbols(text: &str) -> impl Iterator + '_ { + text.lines().filter_map(|l| { + let mut w = l.split_whitespace(); + match w.next() { + Some("config" | "menuconfig") => w.next().map(str::to_string), + _ => None, + } + }) +} + +/// `missing_required`, without options this kernel version does not have (an older longterm +/// tree, or an option renamed upstream): those cannot be turned on and must not block a build. +pub fn missing_required_in(config: &str, defined: &std::collections::HashSet) -> Vec<&'static str> { + missing_required(config).into_iter().filter(|s| defined.contains(*s)).collect() +} + /// What needs `symbols`, for the configuration summary. fn enable_users(symbols: &[&str]) -> &'static str { let net = symbols.iter().any(|s| REQUIRED_NETWORK_SYMBOLS.contains(s) || REQUIRED_NETWORK_FLAGS.contains(s)); @@ -624,10 +673,6 @@ fn enable_users(symbols: &[&str]) -> &'static str { } } -fn enable_what(symbols: &[&str]) -> String { - format!("for {}", enable_users(symbols)) -} - /// The number of =m symbols: how many modules the configuration builds. pub fn module_count(config: &str) -> usize { config.lines().filter(|l| l.starts_with("CONFIG_") && l.ends_with("=m")).count() @@ -905,7 +950,8 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> let (debug_args, debug_text) = debug_info_args(); let own_config = matches!(req.mode, ConfigMode::OwnConfig(_)); - let enable: Vec<&str> = if own_config { vec![] } else { missing_required(&base) }; + let defined = kconfig_symbols(tree)?; + let enable: Vec<&str> = if own_config { vec![] } else { missing_required_in(&base, &defined) }; let mut fixes = vec![ format!("LOCALVERSION set to \"{LOCALVERSION}\""), "SYSTEM_TRUSTED_KEYS set to \"\" (Ubuntu's points at Canonical certificate files that are not in a kernel.org tree)".to_string(), @@ -922,7 +968,7 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> r.run(c, "scripts/config").map(|_| ()) }; if !enable.is_empty() { - fixes.push(format!("Turned on {}: CONFIG_{}", enable_what(&enable), enable.join(", CONFIG_"))); + fixes.push(format!("Turned on for {}: {}", enable_users(&enable), option_list(&enable))); } apply_fixes(&enable)?; @@ -978,11 +1024,11 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> c.arg(format!("LSMOD={}", list.display())).arg("localmodconfig"); r.run(c, "make localmodconfig")?; // localmodconfig drops every module that is not loaded, required ones included: put them back. - let restore = missing_required(&std::fs::read_to_string(tree.join(".config"))?); + let restore = missing_required_in(&std::fs::read_to_string(tree.join(".config"))?, &defined); apply_fixes(&restore)?; olddefconfig()?; if !restore.is_empty() { - fixes.push(format!("Kept after localmodconfig {}: {} options", enable_what(&restore), restore.len())); + fixes.push(format!("Kept after localmodconfig for {}: {} options", enable_users(&restore), restore.len())); } fixes.push(format!("localmodconfig: only drivers for {what}")); notes.push( @@ -998,9 +1044,10 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> } }; expect("LOCALVERSION", &format!("\"{LOCALVERSION}\""))?; - let missing = missing_required(&config); + let missing = missing_required_in(&config, &defined); if !missing.is_empty() { - let what = format!("CONFIG_{} is off: {} would not work with this kernel", missing.join(", CONFIG_"), enable_users(&missing)); + let why = if own_config { "" } else { " (it could not be turned on: an option it depends on is off in the base config)" }; + let what = format!("CONFIG_{} is off{why}: {} would not work with this kernel", missing.join(", CONFIG_"), enable_users(&missing)); if own_config { notes.push(format!("{what}.")); } else { @@ -1576,12 +1623,20 @@ mod tests { // Without netfilter at all, none of them is asked for. let no_netfilter = no_reject.replace("CONFIG_NETFILTER=y\n", ""); assert!(missing_required(&no_netfilter).is_empty()); - // Every option is listed once, in one list, as a plain Kconfig name. - let mut seen = std::collections::HashSet::new(); - for s in REQUIRED_INPUT_SYMBOLS.iter().chain(REQUIRED_BLUETOOTH_SYMBOLS).chain(REQUIRED_NETWORK_FLAGS).chain(REQUIRED_NETWORK_SYMBOLS) { - assert!(s.chars().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_'), "{s}"); - assert!(seen.insert(*s), "{s} listed twice"); - } + // ufw's IPv6 rules need the hl and rt matches; 6.17+ iptables tables need the legacy switch. + let ufw = full.replace("CONFIG_NETFILTER_XT_MATCH_HL=m\n", "").replace("CONFIG_IP6_NF_MATCH_RT=m\n", ""); + assert_eq!(missing_required(&ufw), ["NETFILTER_XT_MATCH_HL", "IP6_NF_MATCH_RT"]); + let pre_617 = full.replace("CONFIG_NETFILTER_XTABLES_LEGACY=y\n", ""); + assert_eq!(missing_required(&pre_617), ["NETFILTER_XTABLES_LEGACY"]); + // An option the tree does not define (an older longterm kernel) is never required. + let mut defined: std::collections::HashSet = REQUIRED_NETWORK_SYMBOLS.iter().map(|s| s.to_string()).collect(); + assert_eq!(missing_required_in(&pre_617, &defined), Vec::<&str>::new()); + defined.insert("NETFILTER_XTABLES_LEGACY".into()); + assert_eq!(missing_required_in(&pre_617, &defined), ["NETFILTER_XTABLES_LEGACY"]); + let k = "config NETFILTER_XTABLES_LEGACY\n\tbool \"x\"\nmenuconfig NF_TABLES\n depends on config_FOO\n# config NOT_ME\n"; + assert_eq!(kconfig_text_symbols(k).collect::>(), ["NETFILTER_XTABLES_LEGACY", "NF_TABLES"]); + assert_eq!(option_list(&["A", "B"]), "CONFIG_A, CONFIG_B"); + assert_eq!(option_list(&["A"; 9]), "9 options"); assert_eq!(enable_users(&["UHID"]), "game controllers or Bluetooth input devices"); assert_eq!(enable_users(&["NFT_REJECT"]), "firewalls, Docker and other containers, VM networks or VPNs"); } @@ -1841,7 +1896,17 @@ mod tests { println!("{}", p.summary.text()); let config = std::fs::read_to_string(p.tree.join(".config")).unwrap(); assert!(missing_required(&config).is_empty(), "{:?}", missing_required(&config)); - for s in ["NFT_REJECT", "IP_NF_TARGET_REJECT", "IP_NF_TARGET_MASQUERADE", "NFT_MASQ", "BRIDGE_NETFILTER", "WIREGUARD", "UHID"] { + for s in [ + "NFT_REJECT", + "IP_NF_TARGET_REJECT", + "IP_NF_TARGET_MASQUERADE", + "NFT_MASQ", + "BRIDGE_NETFILTER", + "WIREGUARD", + "UHID", + "NETFILTER_XT_MATCH_HL", + "IP6_NF_MATCH_RT", + ] { assert!(matches!(config_value(&config, s).as_deref(), Some("y" | "m")), "CONFIG_{s} is off"); } p.discard(); From 2895fb28b03a27401f64e135a4af8023a8e67aa5 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sun, 22 Nov 2026 04:42:57 -0500 Subject: [PATCH 3/3] Log the options Kernel Pop turns on (review nit) Co-Authored-By: Claude Opus 5.5 --- src/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/build.rs b/src/build.rs index 9e075f1..74d1534 100644 --- a/src/build.rs +++ b/src/build.rs @@ -965,6 +965,9 @@ fn configure(req: &BuildRequest, tree: &Path, base_config: &Path, r: &Runner) -> .args(["--set-str", "SYSTEM_REVOCATION_KEYS", ""]) .args(&debug_args) .args(enable_args(enable)); + if !enable.is_empty() { + r.note(format!("Turning on CONFIG_{}", enable.join(", CONFIG_"))); + } r.run(c, "scripts/config").map(|_| ()) }; if !enable.is_empty() {