Package: linux-image-3.16.0-4-amd64
Version: 3.16.7-ckt9-3~deb8u1
Severity: important
Note: I'm not sure which package to blame here. I chose the kernel
because I believe the kernel knows better than anybody else which
modules are suitable to be unloaded and which modules are not, but
this could also be a bug in qemu or a bug in kmod, so feel free to
reassign.
rmmod(8) says:
-f, --force
This option can be extremely dangerous: it has no effect unless
CONFIG_MODULE_FORCE_UNLOAD was set when
the kernel was compiled. With this option, you can remove modules which
are being used, or which are not
designed to be removed, or have been marked as unsafe (see lsmod(8)).
which implicitly means that as long as you don't use --force, rmmod
will refuse to remove a module if it's being used.
Well, I tried this today on a virtual machine running qemu:
lsmod | awk '$3 == 0 { print $1 }' | xargs -r rmmod
and the machine *crashed*, which I think it should count as
"module being used" or "not designed to be removed".
To debug this, I tried to remove modules one by one until problems
started to appear. This is the result:
Attach "lsmod-starting-point.txt" is the output of lsmod before the tests.
Attach "modules-that-may-be-removed.txt" is the list of modules that may
be removed safely, this way:
rmmod `cat modules-that-may-be-removed.txt`
After that, the output of lsmod is like this:
Module Size Used by
evdev 17445 1
autofs4 35529 2
ext4 473802 1
crc16 12343 1 ext4
mbcache 17171 1 ext4
jbd2 82413 1 ext4
virtio_net 26553 0
virtio_blk 17345 3
virtio_pci 17389 0
virtio_ring 17513 3 virtio_blk,virtio_net,virtio_pci
virtio 13058 3 virtio_blk,virtio_net,virtio_pci
and now it comes the fun part:
I'm not using the console but ssh. So I'm using the net.
However:
rmmod virtio_net
works and makes the ssh connection to be lost.
I think this should not happen.
Then it comes the really fun part:
rmmod virtio_pci
also works, but the result is I/O error in the root partition,
which becomes read-only and the system needs to be rebooted.
See last attach "screenshot.png".
I think this should not happen either.
Thanks.
Module Size Used by
joydev 17063 0
hid_generic 12393 0
ppdev 16782 0
usbhid 44460 0
evdev 17445 2
hid 102264 2 hid_generic,usbhid
psmouse 99143 0
serio_raw 12849 0
pcspkr 12595 0
virtio_console 22655 0
virtio_balloon 13047 0
pvpanic 12563 0
parport_pc 26300 0
parport 35749 2 ppdev,parport_pc
ttm 77862 0
drm_kms_helper 49210 0
processor 28221 0
thermal_sys 27642 1 processor
drm 249955 2 ttm,drm_kms_helper
i2c_piix4 20864 0
i2c_core 46012 3 drm,i2c_piix4,drm_kms_helper
button 12944 0
autofs4 35529 2
ext4 473802 1
crc16 12343 1 ext4
mbcache 17171 1 ext4
jbd2 82413 1 ext4
virtio_net 26553 0
virtio_blk 17345 3
ata_generic 12490 0
crc32c_intel 21809 0
ehci_pci 12512 0
uhci_hcd 43499 0
ehci_hcd 69837 1 ehci_pci
usbcore 195340 4 uhci_hcd,ehci_hcd,ehci_pci,usbhid
usb_common 12440 1 usbcore
ata_piix 33592 0
floppy 65068 0
virtio_pci 17389 0
virtio_ring 17513 5
virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_console
virtio 13058 5
virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_console
libata 177457 2 ata_generic,ata_piix
scsi_mod 191405 1 libata
joydev
hid_generic
ppdev
usbhid
hid
psmouse
serio_raw
pcspkr
virtio_console
virtio_balloon
pvpanic
parport_pc
parport
ttm
drm_kms_helper
processor
thermal_sys
drm
i2c_piix4
i2c_core
button
ata_generic
crc32c_intel
ehci_pci
uhci_hcd
ehci_hcd
usbcore
usb_common
ata_piix
floppy
libata
scsi_mod