PM: hibernate: fix resume_store() return value when hibernation not available
Subsystems (6)
PATCH 1/1 PM: hibernate: fix resume_store() return value when hibernation not available
On a laptop with hibernation set up but not actively used, and with secure boot and lockdown enabled kernel, 6.5-rc1 gets stuck on boot with the following repeated messages:
A start job is running for Resume from hibernation using device /dev/system/swap (24s / no limit)
lockdown_is_locked_down: 25311154 callbacks suppressed
Lockdown: systemd-hiberna: hibernation is restricted; see man kernel_lockdown.7
...
Checking the resume code leads to commit cc89c63e2fe3 ("PM: hibernate:
move finding the resume device out of software_resume") which inadvertently changed the return value from resume_store() to 0 when !hibernation_available(). This apparently translates to userspace write() returning 0 as in number of bytes written, and userspace looping indefinitely in the attempt to write the intended value.
Fix this by returning the full number of bytes that were to be written, as that's what was done before the commit.
---
Resend with review/ack tags added and not buried in the thread.
kernel/power/hibernate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/hibernate.c +1 -1
@@ -1166,7 +1166,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,int error;if (!hibernation_available ()) -return 0 ; +return n;if (len && buf[len-1 ] =='\n' ) len--;
Signature · 1 line
2.41.0
Quoted 36 lines · Vlastimil Babka
On a laptop with hibernation set up but not actively used, and with secure boot and lockdown enabled kernel, 6.5-rc1 gets stuck on boot with the following repeated messages:
A start job is running for Resume from hibernation using device
/dev/system/swap(24s / no limit)
lockdown_is_locked_down: 25311154 callbacks suppressed
Lockdown: systemd-hiberna: hibernation is restricted; see man kernel_lockdown.7
...Checking the resume code leads to commit
cc89c63e2fe3("PM: hibernate:
move finding the resume device out ofsoftware_resume") which inadvertently changed the return value fromresume_store()to 0 when !hibernation_available(). This apparently translates to userspacewrite()returning 0 as in number of bytes written, and userspace looping indefinitely in the attempt to write the intended value.Fix this by returning the full number of bytes that were to be written, as that's what was done before the commit.
Fixes cc89c63e2fe3 ("PM: hibernate: move finding the resume device out of software_resume")Signed-off-by Vlastimil Babka <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
Resend with review/ack tags added and not buried in the thread.kernel/power/hibernate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/power/hibernate.c +0
-0
kernel/power/hibernate.c static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
Quoted 9 lines
kernel/power/hibernate.c +1
-2@@ -1166,7 +1166,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,int error;if (!hibernation_available ()) -return 0 ; +return n;if (len && buf[len-1 ] =='\n' ) len--; --
Applied as 6.5-rc material, thanks!