From cab29e9f097dce9a0328a61ce4d1e9ffbb8f55c5 Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Fri, 16 Aug 2024 23:53:00 +0330 Subject: [PATCH] Validate default_kernel global property on set fixes: https://github.com/QubesOS/qubes-issues/issues/8992 --- qubes/app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qubes/app.py b/qubes/app.py index 2a00355b7..7edfea3dc 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -1593,3 +1593,12 @@ def on_property_set_default_dispvm(self, event, name, newvalue, # resetting dispvm to its default value vm.fire_event('property-reset:default_dispvm', name='default_dispvm', oldvalue=oldvalue) + + @qubes.events.handler('property-pre-set:default_kernel') + def on_property_pre_set_default_kernel(self, event, name, newvalue, + oldvalue=None): + # pylint: disable=unused-argument + kernels = [kernel.vid for kernel in self.pools['linux-kernel'].volumes] + if not newvalue in kernels: + raise qubes.exc.QubesException( + 'Invalid kernel: {} !'.format(newvalue))