]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xen/privcmd: unregister xenstore notifier on module exit
authorGuoHan Zhao <zhaoguohan@kylinos.cn>
Wed, 25 Mar 2026 12:02:46 +0000 (20:02 +0800)
committerJuergen Gross <jgross@suse.com>
Thu, 26 Mar 2026 07:57:51 +0000 (08:57 +0100)
Commit 453b8fb68f36 ("xen/privcmd: restrict usage in
unprivileged domU") added a xenstore notifier to defer setting the
restriction target until Xenstore is ready.

XEN_PRIVCMD can be built as a module, but privcmd_exit() leaves that
notifier behind. Balance the notifier lifecycle by unregistering it on
module exit.

This is harmless even if xenstore was already ready at registration
time and the notifier was never queued on the chain.

Fixes: 453b8fb68f3641fe ("xen/privcmd: restrict usage in unprivileged domU")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260325120246.252899-1-zhaoguohan@kylinos.cn>

drivers/xen/privcmd.c

index bbf9ee21306cdeb63bb0a4c43f045659edaff0ea..15ba592236e84570d28e8293b010b3d7208ef5e6 100644 (file)
@@ -1765,6 +1765,9 @@ err_privcmdbuf:
 
 static void __exit privcmd_exit(void)
 {
+       if (!xen_initial_domain())
+               unregister_xenstore_notifier(&xenstore_notifier);
+
        privcmd_ioeventfd_exit();
        privcmd_irqfd_exit();
        misc_deregister(&privcmd_dev);