"modprobe: ERROR: could not insert 'nvidia': Key was rejected by service" due to binutils mismatch

Bug #1921536 reported by dann frazier
42
This bug affects 7 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Undecided
Unassigned
linux-restricted-modules (Ubuntu)
Confirmed
Undecided
Unassigned
nvidia-graphics-drivers-525 (Ubuntu)
Confirmed
Undecided
Unassigned
nvidia-graphics-drivers-535 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

If a user does not have the same version of binutils installed as the one used to produce the nvidia module signature, the module generated at postinst maybe unloadable:

modprobe: ERROR: could not insert 'nvidia': Key was rejected by service

I ran into this when I tried to install the hirsute kernel/nvidia driver on a focal system.

Tags: lunar nvidia
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in linux-restricted-modules (Ubuntu):
status: New → Confirmed
Changed in nvidia-graphics-drivers-525 (Ubuntu):
status: New → Confirmed
Changed in nvidia-graphics-drivers-535 (Ubuntu):
status: New → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

From bug 2014983:

> Fixed by purging everything nvidia, libnvidia, or cuda, and reinstalling through
> the "additional drivers" interface. I also reinstalled linux-headers-$(uname -r).

tags: added: nvidia
tags: added: lunar
Changed in linux (Ubuntu):
status: New → Confirmed
Revision history for this message
Teh Kok How (khteh) wrote :

Please provide complete reinstallation commands.

Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

At a guess:

1. sudo apt remove nvidia-driver-535 nvidia-dkms-535
2. sudo apt purge
3. Reboot.
4. Open the 'Additional Drivers' app in GNOME and use it to reinstall.
5. Reboot again.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Alternatively, just disable Secure Boot in the BIOS :)

Revision history for this message
Teh Kok How (khteh) wrote :

Which one of the two?

Revision history for this message
Teh Kok How (khteh) wrote :

Which one of the two should I install?

Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

> Amd why are ALL the options disabled for me?

It thinks you installed a driver manually from nvidia.com, which Ubuntu doesn't support. Try this:

  /usr/bin/nvidia-installer --uninstall
  # From http://us.download.nvidia.com/XFree86/Linux-x86_64/535.54.03/README/installdriver.html

Also uninstall any packages from previous drivers, which you can find with:

  dpkg -l | grep nvidia | grep -e '\<[345][0-9][0-9]\.'

and also delete any lingering kernel modules, which you can find with:

  find /usr/lib -name nvidia.ko

then reboot and hopefully the 'Additional Drivers' app will behave better.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

nvidia-driver-535 should be best.

Revision history for this message
Teh Kok How (khteh) wrote :

No, there are 2 535 drivers listed in the "Additional Drivers" gnome app. Which one should I install?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

YES: nvidia-driver-535
NO: nvidia-driver-535-open

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Or more generally install whichever one is listed as "tested".

Revision history for this message
Teh Kok How (khteh) wrote :

Done but still doesn't work.

$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

After rebooting, if it still doesn't work then please run:

  journalctl -b0 > journal.txt
  find /var/lib/dkms/nvidia -name make.log

and attach both files here.

Revision history for this message
Teh Kok How (khteh) wrote :

journalctl -b0

Revision history for this message
Teh Kok How (khteh) wrote :

/var/lib/dkms/nvidia/535.54.03/6.2.0-24-generic/x86_64/log/make.log

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

And we're back to the original problem. I'm out of ideas sorry, and would just be googling at this stage.

Jul 03 16:45:29 khteh-p17-2i gdm3[3111]: modprobe: ERROR: could not insert 'nvidia': Key was rejected by service
Jul 03 16:45:29 khteh-p17-2i kernel: Loading of module with unavailable key is rejected

Revision history for this message
Teh Kok How (khteh) wrote :

That sucks.

Revision history for this message
dann frazier (dannf) wrote :

Canonical has provided a signature for an exact set of bytes in the .ko file. The packaging needs to relink the object files into that exact set of bytes on the target system for the signature to match. The relinking is required for license compliance AIUI. binutils does the linking. If you use a different version of binutils, it may generate a different set of bytes that fails the signature check.

Can you elaborate on what you think Ubuntu should be doing differently?

Revision history for this message
Teh Kok How (khteh) wrote :

What do you mean "different version of binutils"? I don't install these myself.

Revision history for this message
Teh Kok How (khteh) wrote :

> Can you elaborate on what you think Ubuntu should be doing differently?
What do you think? I have not been able to use Ubuntu with external monitor for 3 weeks now!

Revision history for this message
dann frazier (dannf) wrote :

This bug is about installing on a system with a different version of binutils. I assumed that is what you are doing because that is what this bug is about. But based on your comment @khteh, I now assume that you are not hitting the problem I reported. Do you have a reason to believe your issue is caused by binutils, or are you just seeing this same error message?

modprobe: ERROR: could not insert 'nvidia': Key was rejected by service

binutils version differences is not the only reason you might see that error. You may be having an issue unrelated to this bug.

One possibility is that the installation method you selected is trying to build its own version of the module, which is not signed by a trusted Canonical key. The fact that you have a make.log at all (as shown in comment #19) is a hint there. nvidia-driver-535 will try to install the prebuilt and signed modules where possible, but if it can't, it will revert to installing the "source" and building an unsigned one instead. If you have the nvidia-dkms-535 driver installed instead of linux-modules-nvidia-535-generic, then that may be what happened.

If that is the case, you can try switching to the prebuilt/signed one by running:

 sudo apt install nvidia-driver-535 linux-modules-nvidia-535-generic
 sudo apt remove nvidia-dkms-535
 # ^ That should only remove nvidia-dkms-535

I hope that fixes your system.

Revision history for this message
Teh Kok How (khteh) wrote :

To no avail

Revision history for this message
Dirk Hoeschen (mail-wz6bkyhu4uqpfausw0ege) wrote :

> sudo apt install nvidia-driver-535 linux-modules-nvidia-535-generic
> sudo apt remove nvidia-dkms-535

Not changing anything!

Revision history for this message
Jason C.H (ctrysbita) wrote :

Same here.

> sudo apt install nvidia-driver-535 linux-modules-nvidia-535-generic
> sudo apt remove nvidia-dkms-535

After doing this you also have to roll back the kernel to 6.2.0-24

Revision history for this message
Dirk Hoeschen (mail-wz6bkyhu4uqpfausw0ege) wrote :

I solved this issue by installing the original Nvidia drivers and signing it with an individual key.

Because it's complicate, only the steps.
* Remove all nvidia packages using "sudo apt purge nvidia*"
* Download the driver from nvidia.com
* Install the NVIDIA-xxx.run package (choose sign with self created key)
* use mokutil --import /usr/share/nvidia/...to import your key
* reboot and enrolling your key into the sim (choose "Enroll MOK" on grub boot screen)

Revision history for this message
Miguel Guedes (migdsb) wrote :

Confirming that Dann Frazier's answer does make it possible to load the Nvidia drivers.

I upgraded to 23.04 (from 22.10) and got kernel 6.2.0-25. Tried all sorts of different ways to manually sign the Nvidia drivers but nothing worked; the Nvidia drivers would always fail to load.

Here all the steps I took to fix this:

# I removed all packages related to Nvidia as I wanted a clean slate
sudo apt purge nvidia*

# Installed the driver but also the pre-signed module as Dann Frazier suggested
sudo apt install nvidia-driver-535 linux-modules-nvidia-535-generic

# The previous command will install some packages for kernel 6.2.0-24 but you're still missing the modules extra package; install it now:
sudo apt install linux-modules-extra-6.2.0-24-generic

Now reboot and make sure you boot into the 6.2.0-24 kernel and the Nvidia drivers should now load.

Revision history for this message
Teh Kok How (khteh) wrote :
Revision history for this message
Teh Kok How (khteh) wrote :

Works now!

`sudo update-secureboot-policy --enroll-key`

reboot and choose enrol MOK

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.