patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [PATCH 1/2] Busybox modprobe is banned
@ 2022-03-21 14:01 Alyssa Ross
  2022-03-21 14:01 ` [PATCH 2/2] host/rootfs: remove unnecessary modprobes Alyssa Ross
  2022-03-22  8:54 ` [PATCH 1/2] Busybox modprobe is banned Alyssa Ross
  0 siblings, 2 replies; 4+ messages in thread
From: Alyssa Ross @ 2022-03-21 14:01 UTC (permalink / raw)
  To: devel

Trying to use modprobe from Busybox has caused nothing but problems.
The latest issue is that it doesn't implement softdep at all.

rootfs.ext4 before: 509M
rootfs.ext4 after: 513M

Thanks-to: Puck Meerburg <puck@puckipedia.com>
---
 host/initramfs/default.nix |  8 +++++++-
 host/rootfs/default.nix    | 10 ++++++++--
 vm/app/catgirl/default.nix | 15 +++++++++++++--
 vm/app/lynx/default.nix    | 15 +++++++++++++--
 vm/sys/net/default.nix     | 15 +++++++++++++--
 5 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix
index b207ace..5ce198a 100644
--- a/host/initramfs/default.nix
+++ b/host/initramfs/default.nix
@@ -16,7 +16,7 @@ let
   linux = rootfs.kernel;
 
   packages = [
-    pkgsStatic.mdevd pkgsStatic.execline
+    pkgsStatic.execline pkgsStatic.kmod pkgsStatic.mdevd
 
     (pkgsStatic.cryptsetup.override {
       programs = {
@@ -29,7 +29,13 @@ let
     (busybox.override {
       enableStatic = true;
       extraConfig = ''
+        CONFIG_DEPMOD n
         CONFIG_FINDFS n
+        CONFIG_INSMOD n
+        CONFIG_LSMOD n
+        CONFIG_MODINFO n
+        CONFIG_MODPROBE n
+        CONFIG_RMMOD n
       '';
     })
   ];
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index b9fabee..2f2c368 100644
--- a/host/rootfs/default.nix
+++ b/host/rootfs/default.nix
@@ -4,7 +4,7 @@
 { pkgs ? import <nixpkgs> {} }: pkgs.pkgsStatic.callPackage (
 
 { lib, stdenv, runCommand, writeReferencesToFile, s6-rc, tar2ext4
-, busybox, cloud-hypervisor, cryptsetup, execline, jq, mdevd, s6
+, busybox, cloud-hypervisor, cryptsetup, execline, jq, kmod, mdevd, s6
 , s6-linux-utils, s6-portable-utils, socat, util-linuxMinimal, xorg
 }:
 
@@ -20,7 +20,7 @@ let
   foot = pkgsGui.foot.override { allowPgo = false; };
 
   packages = [
-    cloud-hypervisor execline jq mdevd s6 s6-linux-utils
+    cloud-hypervisor execline jq kmod mdevd s6 s6-linux-utils
     s6-portable-utils s6-rc socat start-vm
 
     (cryptsetup.override {
@@ -33,8 +33,14 @@ let
 
     (busybox.override {
       extraConfig = ''
+        CONFIG_DEPMOD n
         CONFIG_FINDFS n
         CONFIG_INIT n
+        CONFIG_INSMOD n
+        CONFIG_LSMOD n
+        CONFIG_MODINFO n
+        CONFIG_MODPROBE n
+        CONFIG_RMMOD n
       '';
     })
   ] ++ (with pkgsGui; [ foot westonLite ]);
diff --git a/vm/app/catgirl/default.nix b/vm/app/catgirl/default.nix
index ed897eb..716e7dd 100644
--- a/vm/app/catgirl/default.nix
+++ b/vm/app/catgirl/default.nix
@@ -9,7 +9,7 @@ pkgs.pkgsStatic.callPackage (
 
 { lib, stdenv, runCommand, writeReferencesToFile, buildPackages
 , s6-rc, tar2ext4
-, busybox, cacert, catgirl, execline, mdevd, s6, s6-linux-utils
+, busybox, cacert, catgirl, execline, kmod, mdevd, s6, s6-linux-utils
 , s6-portable-utils
 }:
 
@@ -17,7 +17,18 @@ let
   inherit (lib) cleanSource cleanSourceWith concatMapStringsSep;
 
   packages = [
-    busybox catgirl execline mdevd s6 s6-linux-utils s6-portable-utils s6-rc
+    catgirl execline kmod mdevd s6 s6-linux-utils s6-portable-utils s6-rc
+
+    (busybox.override {
+      extraConfig = ''
+        CONFIG_DEPMOD n
+        CONFIG_INSMOD n
+        CONFIG_LSMOD n
+        CONFIG_MODINFO n
+        CONFIG_MODPROBE n
+        CONFIG_RMMOD n
+      '';
+    })
   ];
 
   packagesSysroot = runCommand "packages-sysroot" {
diff --git a/vm/app/lynx/default.nix b/vm/app/lynx/default.nix
index 90fda0f..72bff7f 100644
--- a/vm/app/lynx/default.nix
+++ b/vm/app/lynx/default.nix
@@ -9,7 +9,7 @@ pkgs.pkgsStatic.callPackage (
 
 { lib, stdenv, runCommand, writeReferencesToFile, buildPackages
 , s6-rc, tar2ext4
-, busybox, cacert, execline, lynx, mdevd, s6, s6-linux-utils
+, busybox, cacert, execline, kmod, lynx, mdevd, s6, s6-linux-utils
 , s6-portable-utils
 }:
 
@@ -17,7 +17,18 @@ let
   inherit (lib) cleanSource cleanSourceWith concatMapStringsSep;
 
   packages = [
-    busybox execline lynx mdevd s6 s6-linux-utils s6-portable-utils s6-rc
+    execline kmod lynx mdevd s6 s6-linux-utils s6-portable-utils s6-rc
+
+    (busybox.override {
+      extraConfig = ''
+        CONFIG_DEPMOD n
+        CONFIG_INSMOD n
+        CONFIG_LSMOD n
+        CONFIG_MODINFO n
+        CONFIG_MODPROBE n
+        CONFIG_RMMOD n
+      '';
+    })
   ];
 
   packagesSysroot = runCommand "packages-sysroot" {
diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix
index a9e1fdc..62a13bb 100644
--- a/vm/sys/net/default.nix
+++ b/vm/sys/net/default.nix
@@ -9,7 +9,7 @@ pkgs.pkgsStatic.callPackage (
 
 { lib, stdenv, runCommand, writeReferencesToFile, buildPackages
 , s6-rc, tar2ext4, xorg
-, busybox, connmanMinimal, dbus, execline, mdevd, nftables, s6
+, busybox, connmanMinimal, dbus, execline, kmod, mdevd, nftables, s6
 , s6-linux-utils, s6-portable-utils
 }:
 
@@ -19,9 +19,20 @@ let
   connman = connmanMinimal;
 
   packages = [
-    busybox connman dbus execline mdevd s6 s6-linux-utils
+    connman dbus execline kmod mdevd s6 s6-linux-utils
     s6-portable-utils s6-rc
 
+    (busybox.override {
+      extraConfig = ''
+        CONFIG_DEPMOD n
+        CONFIG_INSMOD n
+        CONFIG_LSMOD n
+        CONFIG_MODINFO n
+        CONFIG_MODPROBE n
+        CONFIG_RMMOD n
+      '';
+    })
+
     (nftables.override { withCli = false; })
   ];
 
-- 
2.35.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] host/rootfs: remove unnecessary modprobes
  2022-03-21 14:01 [PATCH 1/2] Busybox modprobe is banned Alyssa Ross
@ 2022-03-21 14:01 ` Alyssa Ross
  2022-03-22  8:36   ` Alyssa Ross
  2022-03-22  8:54 ` [PATCH 1/2] Busybox modprobe is banned Alyssa Ross
  1 sibling, 1 reply; 4+ messages in thread
From: Alyssa Ross @ 2022-03-21 14:01 UTC (permalink / raw)
  To: devel

Now that we're using a proper modprobe implementation, some of these
weird modprobes we shouldn't have needed in the first place can
actually be removed.
---
 host/rootfs/etc/mdev/net/add |  5 +---
 host/start-vm/modprobe.rs    | 49 ------------------------------------
 host/start-vm/start-vm.rs    |  4 ---
 3 files changed, 1 insertion(+), 57 deletions(-)
 delete mode 100644 host/start-vm/modprobe.rs

diff --git a/host/rootfs/etc/mdev/net/add b/host/rootfs/etc/mdev/net/add
index 959d73a..7b282e7 100755
--- a/host/rootfs/etc/mdev/net/add
+++ b/host/rootfs/etc/mdev/net/add
@@ -5,10 +5,7 @@
 # Assign the whole IOMMU group containing this device to the network
 # VM.
 
-if {
-  forx -pE module { vfio-pci vfio_iommu_type1 }
-  modprobe $module
-}
+if { modprobe vfio-pci }
 
 importas -i devpath DEVPATH
 
diff --git a/host/start-vm/modprobe.rs b/host/start-vm/modprobe.rs
deleted file mode 100644
index 6186820..0000000
--- a/host/start-vm/modprobe.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: EUPL-1.2
-// SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
-
-use std::ffi::OsStr;
-use std::fmt::{self, Display, Formatter};
-use std::io;
-use std::os::unix::prelude::*;
-use std::process::{Command, ExitStatus};
-
-#[derive(Debug)]
-pub enum ModprobeError {
-    Spawn(io::Error),
-    Fail(ExitStatus),
-}
-
-impl Display for ModprobeError {
-    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
-        use ModprobeError::*;
-        match self {
-            Spawn(e) => write!(f, "failed to spawn modprobe: {}", e),
-            Fail(status) => {
-                if let Some(code) = status.code() {
-                    write!(f, "modprobe exited with status {}", code)
-                } else {
-                    write!(f, "modprobe killed by signal {}", status.signal().unwrap())
-                }
-            }
-        }
-    }
-}
-
-pub fn modprobe<I, S>(module_names: I) -> Result<(), ModprobeError>
-where
-    I: IntoIterator<Item = S>,
-    S: AsRef<OsStr>,
-{
-    let status = Command::new("modprobe")
-        .arg("-q")
-        .arg("--")
-        .args(module_names)
-        .status()
-        .map_err(ModprobeError::Spawn)?;
-
-    if status.success() {
-        Ok(())
-    } else {
-        Err(ModprobeError::Fail(status))
-    }
-}
diff --git a/host/start-vm/start-vm.rs b/host/start-vm/start-vm.rs
index becbe5c..0d08eaa 100644
--- a/host/start-vm/start-vm.rs
+++ b/host/start-vm/start-vm.rs
@@ -2,7 +2,6 @@
 // SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
 
 mod ch;
-mod modprobe;
 mod net;
 
 use std::env::{args, current_dir};
@@ -12,7 +11,6 @@ use std::os::unix::prelude::*;
 use std::path::PathBuf;
 use std::process::{exit, Command};
 
-use modprobe::modprobe;
 use net::{format_mac, net_setup, NetConfig};
 
 macro_rules! errx {
@@ -30,8 +28,6 @@ macro_rules! err {
 }
 
 fn main() {
-    modprobe(&["kvm-intel"]).unwrap_or_else(err!(1, "modprobe kvm-intel"));
-
     let mut command = Command::new("s6-notifyoncheck");
     command.args(&["-dc", "test -S env/cloud-hypervisor.sock"]);
     command.arg("cloud-hypervisor");
-- 
2.35.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] host/rootfs: remove unnecessary modprobes
  2022-03-21 14:01 ` [PATCH 2/2] host/rootfs: remove unnecessary modprobes Alyssa Ross
@ 2022-03-22  8:36   ` Alyssa Ross
  0 siblings, 0 replies; 4+ messages in thread
From: Alyssa Ross @ 2022-03-22  8:36 UTC (permalink / raw)
  To: Alyssa Ross, devel

This patch has been committed as d55913426b0f26d8c586bc1fdd0e4cdb73d77777,
which can be viewed online at
https://spectrum-os.org/git/spectrum/commit/?id=d55913426b0f26d8c586bc1fdd0e4cdb73d77777.

This is an automated message.  Send comments/questions/requests to:
Alyssa Ross <hi@alyssa.is>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Busybox modprobe is banned
  2022-03-21 14:01 [PATCH 1/2] Busybox modprobe is banned Alyssa Ross
  2022-03-21 14:01 ` [PATCH 2/2] host/rootfs: remove unnecessary modprobes Alyssa Ross
@ 2022-03-22  8:54 ` Alyssa Ross
  1 sibling, 0 replies; 4+ messages in thread
From: Alyssa Ross @ 2022-03-22  8:54 UTC (permalink / raw)
  To: Alyssa Ross, devel

This patch has been committed as cf7e089a907439c6293f85bc46e9c9f6319d7509,
which can be viewed online at
https://spectrum-os.org/git/spectrum/commit/?id=cf7e089a907439c6293f85bc46e9c9f6319d7509.

This is an automated message.  Send comments/questions/requests to:
Alyssa Ross <hi@alyssa.is>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-22  8:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 14:01 [PATCH 1/2] Busybox modprobe is banned Alyssa Ross
2022-03-21 14:01 ` [PATCH 2/2] host/rootfs: remove unnecessary modprobes Alyssa Ross
2022-03-22  8:36   ` Alyssa Ross
2022-03-22  8:54 ` [PATCH 1/2] Busybox modprobe is banned Alyssa Ross

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).