Uninstall fail to properly remove modules when manually signed
I'm using secure boot and i'm signing my modules at each module/kernel update. My signed modules are stored in the path: /lib/modules/[kernel version]/updates/dkms/
Typical example with installed versions on Debian 11: (but same issue exists on Debian 10 with previous kernels & dkms versions) dkms/stable,now 2.8.4-3 zfs-dkms/stable,now 2.0.3-9 linux-image-5.10.0-8-amd64/stable linux-image-5.10.0-9-amd64/stable Then removing the 5.10.0-8 stuff.
i'm signing my modules the following way: for mod in /lib/modules/5.10.0-9-amd64/updates/dkms/*ko do /usr/lib/linux-kbuild-5.10/scripts/sign-file sha256 /root/MOK.priv /root/MOK.der $mod done
The way I'm doing is leading to an issue when uninstalling a kernel: Because of the signature, the modules binaries located in /lib/modules/[kernel version]/updates/dkms/ differs from the version of /var/lib/dkms/zfs/kernel-[kernel version]-[arch]/module. Therefore the function find_actual_dest_module_location locate the modules properly, but the comparison of binaries fails and the correct path is not returned.
The issue is localed in the /usr/sbin/dkms script, in the below function: find_actual_dest_module_location() { ... for l in $locations; do installed=$(compressed_or_uncompressed "${install_tree}/${kernelver}${l}" "${dest_module_name[${count}]}") if [[ -n "${installed}" ]] && diff "${dkms_owned}" "${installed}" > /dev/null 2>&1; then echo "${l}" return 0 fi done ... }
it end-up with this kind of message: _zavl.ko:
- Uninstallation
- Deleting from: /lib/modules/5.10.0-8-amd64/ rmdir: impossible de supprimer '': Aucun fichier ou dossier de ce type
- Original module
- No original module was found for this module on this kernel.
- Use the dkms install command to reinstall any previous module version._
And of course the path /lib/modules still contains unexpected old kernel versions directories.
Manually signing modules seems to be a bad practice for dkms behavior. Properly setting the automatic signature on build solve the issue on Debian 11. Solved issue in Debian 10 by using bpo version of dkms.
So this should be closed? You should sign as described in the README (for now).