From dfde6640ebad505e7af7dc204a0e2c16dfddfb1e Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 10 Apr 2023 16:00:34 +0800 Subject: [PATCH 1/2] systemd: Set /dev/kvm mode to 0660 The default /dev/kvm mode is 0666 and we consider it "not so safe". Like Tim said: "I'm also authenticating to my system all the time and don't do a chmod -R 777 / after every boot." With this option, the /dev/kvm mode is set to 0660 and it's tagged "uaccess" so systemd-logind will add an ACL entry for users logged-in locally. --- chapter08/systemd.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/chapter08/systemd.xml b/chapter08/systemd.xml index fcac04602..31d89e01a 100644 --- a/chapter08/systemd.xml +++ b/chapter08/systemd.xml @@ -66,6 +66,7 @@ meson --prefix=/usr \ -Dman=false \ -Dmode=release \ -Dpamconfdir=no \ + -Ddev-kvm-mode=0660 \ -Ddocdir=/usr/share/doc/systemd-&systemd-version; \ .. @@ -167,6 +168,15 @@ meson --prefix=/usr \ functional on LFS. + + + -Ddev-kvm-mode=0660 + + The default udev rule would allow all users to access + /dev/kvm. The editors + consider it dangerous. This option overrides it. + + Compile the package: From a4b0c6d60a7d6c112fbc6a43e868ac65b34b16bf Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 10 Apr 2023 16:17:17 +0800 Subject: [PATCH 2/2] eudev: Set /dev/kvm mode to 0660 and tag it "uaccess" See the parent commit for rationale. --- chapter08/eudev.xml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/chapter08/eudev.xml b/chapter08/eudev.xml index 0cce469e1..f4c5ac5d2 100644 --- a/chapter08/eudev.xml +++ b/chapter08/eudev.xml @@ -40,8 +40,6 @@ Installation of Eudev - - First fix the location of udev rules in the .pc file: sed -i '/udevdir/a udev_dir=${udevdir}' src/udev/udev.pc.in @@ -88,6 +86,20 @@ make -f &udev-lfs-version;/Makefile.lfs install configuring + + /etc/udev/rules.d/65-kvm.rules + + + + The default udev rule installed by Eudev would allow all users to + access /dev/kvm. The editors + consider it dangerous. Create a configuration file to override it: + + +cat > /etc/udev/rules.d/65-kvm.rules << "EOF" +KERNEL=="kvm", GROUP="kvm", MODE="0660", TAG+="uaccess" +EOF + /etc/udev/hwdb.bin