]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xen: take system_transition_mutex on suspend
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Sun, 21 Sep 2025 16:28:47 +0000 (18:28 +0200)
committerJuergen Gross <jgross@suse.com>
Mon, 22 Sep 2025 08:16:55 +0000 (10:16 +0200)
Xen's do_suspend() calls dpm_suspend_start() without taking required
system_transition_mutex. Since 12ffc3b1513eb moved the
pm_restrict_gfp_mask() call, not taking that mutex results in a WARN.

Take the mutex in do_suspend(), and use mutex_trylock() to follow
how enter_state() does this.

Suggested-by: Jürgen Groß <jgross@suse.com>
Fixes: 12ffc3b1513eb "PM: Restrict swap use to later in the suspend sequence"
Link: https://lore.kernel.org/xen-devel/aKiBJeqsYx_4Top5@mail-itl/
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Cc: stable@vger.kernel.org # v6.16+
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20250921162853.223116-1-marmarek@invisiblethingslab.com>

drivers/xen/manage.c

index 1f5a7a42fc32783063ef2fcb07d27a90ffa30cae..e20c40a62e64e29e08ec54f43399b8a017e26fe2 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/reboot.h>
 #include <linux/sysrq.h>
 #include <linux/stop_machine.h>
+#include <linux/suspend.h>
 #include <linux/freezer.h>
 #include <linux/syscore_ops.h>
 #include <linux/export.h>
@@ -95,10 +96,16 @@ static void do_suspend(void)
 
        shutting_down = SHUTDOWN_SUSPEND;
 
+       if (!mutex_trylock(&system_transition_mutex))
+       {
+               pr_err("%s: failed to take system_transition_mutex\n", __func__);
+               goto out;
+       }
+
        err = freeze_processes();
        if (err) {
                pr_err("%s: freeze processes failed %d\n", __func__, err);
-               goto out;
+               goto out_unlock;
        }
 
        err = freeze_kernel_threads();
@@ -155,6 +162,8 @@ out_resume_end:
 
 out_thaw:
        thaw_processes();
+out_unlock:
+       mutex_unlock(&system_transition_mutex);
 out:
        shutting_down = SHUTDOWN_INVALID;
 }