Skip to contentSkip to conversation

PM: hibernate: Fix the exclusive get block device in test_resume mode

PATCH Applied Chen Yu 3 participants 3 messages Aug 23, 2023

Subsystems (2)
lore
Share & tools
lore

Chen Yu

author
#0 lore raw

PATCH 1/1 PM: hibernate: Fix the exclusive get block device in test_resume mode

commit 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode") fixes a hibernation issue under test_resume mode. That commit is supposed to open the block device in non-exclusive mode when in test_resume. However the code did the opposite, which is against its description.

Fix this by really disabling exclusive mode under test_resume.

Reported-by [email protected]
Fixes 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
---
 kernel/power/swap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/power/swap.c +2 -2
index f6ebcd00c410..c12b34dd529c 100644
@@ -1518,7 +1518,7 @@ static void *swsusp_holder;
 
 int swsusp_check(bool snapshot_test)
 {
-	void *holder = snapshot_test ? &swsusp_holder : NULL;
+	void *holder = snapshot_test ? NULL : &swsusp_holder;
 	int error;
 
 	hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ,
@@ -1573,7 +1573,7 @@ void swsusp_close(bool snapshot_test)
 		return;
 	}
 
-	blkdev_put(hib_resume_bdev, snapshot_test ? &swsusp_holder : NULL);
+	blkdev_put(hib_resume_bdev, snapshot_test ? NULL : &swsusp_holder);
 }
 
 /**
Signature · 1 line
2.25.1
#1 lore raw
Quoted 30 lines · Chen Yu

commit 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode") fixes a hibernation issue under test_resume mode. That commit is supposed to open the block device in non-exclusive mode when in test_resume. However the code did the opposite, which is against its description.

Fix this by really disabling exclusive mode under test_resume.

Reported-by [email protected]
Fixes 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
---
 kernel/power/swap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/power/swap.c +1 -1
index f6ebcd00c410..c12b34dd529c 100644
@@ -1518,7 +1518,7 @@ static void *swsusp_holder;
 
 int swsusp_check(bool snapshot_test)
 {
-	void *holder = snapshot_test ? &swsusp_holder : NULL;
+	void *holder = snapshot_test ? NULL : &swsusp_holder;
 	int error;
 
 	hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ,

kernel/power/swap.c void swsusp_close(bool snapshot_test) · line 1577

Quoted 6 lines
kernel/power/swap.c +1 -1
@@ -1573,7 +1573,7 @@ void swsusp_close(bool snapshot_test)
 		return;
 	}
 
-	blkdev_put(hib_resume_bdev, snapshot_test ? &swsusp_holder : NULL);
+	blkdev_put(hib_resume_bdev, snapshot_test ? NULL : &swsusp_holder);
 }

This issue was reported in an Intel internal ticket by private syzkaller on 25/May/2023.
Thanks for consideration if possible.

Best Regards,
Thanks!

Quoted 5 lines
kernel/power/swap.c +0 -0
 /**
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
In reply to Chen Yu
Quoted 31 lines · Chen Yu

commit 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode") fixes a hibernation issue under test_resume mode. That commit is supposed to open the block device in non-exclusive mode when in test_resume. However the code did the opposite, which is against its description.

Fix this by really disabling exclusive mode under test_resume.

Reported-by [email protected]
Fixes 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
---
 kernel/power/swap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/power/swap.c +1 -1
index f6ebcd00c410..c12b34dd529c 100644
@@ -1518,7 +1518,7 @@ static void *swsusp_holder;
 
 int swsusp_check(bool snapshot_test)
 {
-       void *holder = snapshot_test ? &swsusp_holder : NULL;
+       void *holder = snapshot_test ? NULL : &swsusp_holder;
        int error;
 
        hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ,

kernel/power/swap.c void swsusp_close(bool snapshot_test)

Quoted 9 lines
kernel/power/swap.c +1 -2
@@ -1573,7 +1573,7 @@ void swsusp_close(bool snapshot_test)
                return;
        }
 
-       blkdev_put(hib_resume_bdev, snapshot_test ? &swsusp_holder : NULL);
+       blkdev_put(hib_resume_bdev, snapshot_test ? NULL : &swsusp_holder);
 }
 
 /**
--

Applied as 6.6 material, thanks!