Skip to content

boot.initrd.luks: remove x86_64/i586 AES modules #85074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2020

Conversation

Emantor
Copy link
Member

@Emantor Emantor commented Apr 12, 2020

Motivation for this change

Commit 1d2c3279311e4f03fcf164e1366f2fda9f4bfccf in the upstream kernel
repository removed support for the scalar x86_64 and i586 AES
assembly implementations, since the generic AES implementation generated
by the compiler is faster for both platforms. Remove the modules from
the cryptoModules list. This causes a regression for kernel versions
>=5.4 which include the removal. This should have no negative impact on
AES performance on older kernels since the generic implementation should
be faster there as well since the implementation was hardly touched from
its initial submission.

Fixes #84842

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Commit 1d2c3279311e4f03fcf164e1366f2fda9f4bfccf in the upstream kernel
repository removed support for the scalar x86_64 and i586 AES
assembly implementations, since the generic AES implementation generated
by the compiler is faster for both platforms. Remove the modules from
the cryptoModules list. This causes a regression for kernel versions
>=5.4 which include the removal. This should have no negative impact on
AES performance on older kernels since the generic implementation should
be faster there as well since the implementation was hardly touched from
its initial submission.

Fixes NixOS#84842
@Emantor Emantor force-pushed the fix/boot_kernel_module branch from 86dbabf to 61da203 Compare April 12, 2020 13:13
@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Apr 12, 2020
Copy link
Contributor

@worldofpeace worldofpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I've done no testing, but I don't think we really need it according to how you've outlined this change.

@worldofpeace
Copy link
Contributor

perhaps @ivanbrennan can validate this?

@ivanbrennan
Copy link
Member

perhaps @ivanbrennan can validate this?

@worldofpeace I'm happy to, but do you know how I could test it without risking locking myself out of my system?

@Emantor
Copy link
Member Author

Emantor commented Apr 14, 2020

You can probably test this with nixos-rebuild build-vm -I nixpkgs=/path/to/this/pr/checked/out and starting the VM afterwards.

@ivanbrennan
Copy link
Member

@worldofpeace @Emantor I tested using build-vm as suggested, and as far as I can tell it looks good! The FATAL warning is gone, the build succeeded, and I was able to run the vm. That doesn't test the drive decryption, but it certainly sounds like that should work.

Again, since I only have access to one machine (and need it for work), I'm hesitant to try it for real (not in a vm, actually rebuild and reboot), but I'm probably being too cautious.

For reference, my test involved:

  1. checking out the PR branch,
git clone git@github.com:Emantor/nixpkgs.git -b fix/boot_kernel_module ./test-nixpkgs
  1. building against that checkout,
sudo nixos-rebuild build-vm -I nixpkgs=./test-nixpkgs --max-jobs 1
  1. running the resulting vm,
./result/bin/run-nixosbox-vm

The full build logs are in this gist: https://gist.github.com/ivanbrennan/e006577dd65d26d6a6f20435e9912f57#file-nixos-build-vm-log

The kernel modules section can also be seen here:
https://gist.github.com/ivanbrennan/e006577dd65d26d6a6f20435e9912f57#file-kernel-modules-log

I noticed a bunch of warnings related to udev rules, like:

substituteStream(): WARNING: pattern '"/sbin/modprobe' doesn't match anything in file '/nix/store/0l4g1v3jj653psy5db80qajii7ql40s2-udev-rules/00-path.rules'

The relevant section of the build logs can be seen here: https://gist.github.com/ivanbrennan/e006577dd65d26d6a6f20435e9912f57#file-udev-rules-log

I don't think the udev rules warnings are related, nor do they look problematic -- just something I noticed when searching the logs for "fatal", "error", and "warning"

@Emantor
Copy link
Member Author

Emantor commented Apr 27, 2020

@ivanbrennan

Again, since I only have access to one machine (and need it for work), I'm hesitant to try it for real (not in a vm, actually rebuild and reboot), but I'm probably being too cautious.

Since this is NixOS, even if the new system doesn't boot you can still start an older generation from the boot menu which will include the old generated initramfs with the module. The only thing which could remove the generation would be automatic run of nix-collect-garbage -d, ensure that this is not enabled in your configuration.

@ivanbrennan
Copy link
Member

@Emantor

Since this is NixOS, even if the new system doesn't boot you can still start an older generation from the boot menu which will include the old generated initramfs with the module. The only thing which could remove the generation would be automatic run of nix-collect-garbage -d, ensure that this is not enabled in your configuration.

When I boot up, I'm prompted for the passphrase to decrypt the root drive before arriving at the boot menu (where generations are listed). This is why I'm not sure I'd be able to rollback if it went wrong.

@Emantor
Copy link
Member Author

Emantor commented Apr 27, 2020

When I boot up, I'm prompted for the passphrase to decrypt the root drive before arriving at the boot menu (where generations are listed). This is why I'm not sure I'd be able to rollback if it went wrong.

Hm, than support for decryption should be in the used bootloader, which from your description should be grub. Since this initial decryption to access the boot partition does not use the kernel at all, the grub decryption shouldn't break even if we remove the kernel module. Please confirm this from your configuration, it should contain something like:

    boot.loader.grub = {
      enable = true;
      version = 2;
      device = "nodev";
      efiSupport = true;
      enableCryptodisk = true;
    };

(copied from the NixOS wiki here). This would mean that it should also be safe to test this PR on your system. Of course I understand if you are still reluctant to test the change on your production system, no pressure 😃. It would be helpful to have a minimal reproducible configuration, than I could test this against a local VM.

@ivanbrennan
Copy link
Member

ivanbrennan commented Apr 27, 2020

@Emantor I'm using the systemd-boot EFI boot loader in this case:

boot.loader.systemd-boot.enable = true;

(I'm no expert, but on this machine, a Dell XPS 13 9360, I had to go with EFI rather than grub to get things working.)

Nonetheless, it sounds like your main point -- that the drive decryption doesn't use the kernel -- still applies.

I'll put a minimal reproducible configuration together and post it here. Thanks for all your help, by the way!

@ivanbrennan
Copy link
Member

@Emantor I was mistaken - on bootup, I'm not prompted to decrypt the drive until after choosing a generation. It had been a while since I did a full reboot. Sorry for the confusion.

@Emantor
Copy link
Member Author

Emantor commented Apr 30, 2020

@Emantor I was mistaken - on bootup, I'm not prompted to decrypt the drive until after choosing a generation. It had been a while since I did a full reboot. Sorry for the confusion.

Than a test on your primary machine shouldn't block on anything 👍

@ivanbrennan
Copy link
Member

@worldofpeace @Emantor Is there anything else I can do to help this along?

@Emantor
Copy link
Member Author

Emantor commented May 5, 2020

@worldofpeace @Emantor Is there anything else I can do to help this along?

You could test this on your main machine, alternatively post a minimal configuration to reproduce your bug, than I can test this fix. Testing on your machine can be done with:
nixos-rebuild switch -I nixpkgs=/path/to/this/pr/checked/out and a reboot, if it doesn't work just choose an older generation. Make sure you don't have automatic garbage collection enabled.

I don't currently have the time to come up with a reproducing configuration myself, unfortunately 😞

@ivanbrennan
Copy link
Member

@Emantor Here's my attempt at a minimal reproducible config:
https://github.com/ivanbrennan/nixbox/tree/19730f0ad57531451093ae2dea4dde694b30a31e

I built a vm with it and was able to get to the login prompt. I imagine hardware-configuration.nix would require some changes to run on a different machine (e.g. device ids).

@ivanbrennan
Copy link
Member

@worldofpeace @Emantor I tested this on my machine and rebooted. It all worked correctly 👍

As suggested, I rebuilt with

nixos-rebuild switch -I nixpkgs=/path/to/this/pr/checked/out

rebooted, and was able to decrypt the drive and log into the system without incident.

@ivanbrennan
Copy link
Member

@worldofpeace Is there anything else I can do to help this get merged?

Copy link
Member

@fpletz fpletz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Also wondering why this wasn't merged sooner.

@fpletz fpletz merged commit a8fd3c7 into NixOS:master Jul 11, 2020
@ivanbrennan
Copy link
Member

@fpletz Thanks! The delay was mostly because I was afraid to test this change (with a rebuild and full reboot) on my one (and currently only) machine. I finally did, however, and it worked out fine.

ivanbrennan added a commit to ivanbrennan/nixbox that referenced this pull request Jul 19, 2020
Now that the x86_64/i586 AES modules have been removed from
boot.initrd.luks (see NixOS/nixpkgs#85074), and
that change has made it into the nixos-unstable channel,
  https://github.com/NixOS/nixpkgs-channels/tree/a5cc7d3197705f933d88e97c0c61849219ce76c1
reintroduce the changes that are needed for NixOS 20.03
  https://nixos.org/nixos/manual/release-notes.html#sec-release-20.03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Luks: module aes_x86_64 not found in linux kernel
4 participants