Comment 5 for bug 2054127

Revision history for this message
Mate Kukri (mkukri) wrote (last edit ):

Do you mean by "teardown version" the original one in peimage code? I don't think there is that specific problem because the only signed grub module that hooks these functions is peimage. And if you chainload multiple copies of GRUB itself (by extension the peimage module contained within) they always load-unload in a stack like manner because we only support chainloading applications.

We can and should get rid of unloading modules at least in secure boot mode, but that wouldnt help with this specific bug sadly. the problem here is that when grub itself exits, the module fini functions are *not called*, apparently by design.
But the systab pointers hooked are system global to UEFI, so we have to re-install them if we want to allow exiting grub itself without resetting the system.

I think moving the hook install/removal to before/after EFI image entry and exit is the right approach here, because with that the hooks arent installed by the time anything can interact with the copy of grub that installed the hooks, and child images running via peimage cannot unload their parent without first exiting themselves. (because there are stackframes pointing to the parent grub anyhow)