public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode
  2023-08-23 16:13 [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode Chen Yu
@ 2023-08-23  9:18 ` Pengfei Xu
  2023-08-23 12:44 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Pengfei Xu @ 2023-08-23  9:18 UTC (permalink / raw)
  To: Chen Yu
  Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm,
	linux-kernel, Chenzhou Feng, syzbot+38d04642cea49f3a3d2e

On 2023-08-24 at 00:13:29 +0800, Chen Yu wrote:
> 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: syzbot+38d04642cea49f3a3d2e@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/lkml/000000000000761f5f0603324129@google.com/
> Fixes: 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
>  kernel/power/swap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index f6ebcd00c410..c12b34dd529c 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -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);
>  }

Reported-by: Pengfei Xu <pengfei.xu@intel.com>

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

Best Regards,
Thanks!

>  
>  /**
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode
  2023-08-23 16:13 [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode Chen Yu
  2023-08-23  9:18 ` Pengfei Xu
@ 2023-08-23 12:44 ` Rafael J. Wysocki
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2023-08-23 12:44 UTC (permalink / raw)
  To: Chen Yu
  Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm,
	linux-kernel, Chenzhou Feng, syzbot+38d04642cea49f3a3d2e

On Wed, Aug 23, 2023 at 10:19 AM Chen Yu <yu.c.chen@intel.com> wrote:
>
> 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: syzbot+38d04642cea49f3a3d2e@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/lkml/000000000000761f5f0603324129@google.com/
> Fixes: 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
>  kernel/power/swap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index f6ebcd00c410..c12b34dd529c 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -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);
>  }
>
>  /**
> --

Applied as 6.6 material, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode
@ 2023-08-23 16:13 Chen Yu
  2023-08-23  9:18 ` Pengfei Xu
  2023-08-23 12:44 ` Rafael J. Wysocki
  0 siblings, 2 replies; 3+ messages in thread
From: Chen Yu @ 2023-08-23 16:13 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, Pavel Machek
  Cc: linux-pm, linux-kernel, Chenzhou Feng, Chen Yu,
	syzbot+38d04642cea49f3a3d2e

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: syzbot+38d04642cea49f3a3d2e@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/lkml/000000000000761f5f0603324129@google.com/
Fixes: 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
 kernel/power/swap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index f6ebcd00c410..c12b34dd529c 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -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);
 }
 
 /**
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-23 12:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23 16:13 [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode Chen Yu
2023-08-23  9:18 ` Pengfei Xu
2023-08-23 12:44 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox