Re: [PATCH] hibernate: Allow uswsusp to write to swap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 4, 2020 at 4:45 PM Darrick J. Wong <darrick.wong@xxxxxxxxxx> wrote:
On Wed, Mar 04, 2020 at 09:23:27AM +0100, Domenico Andreoli wrote:
> From: Domenico Andreoli <domenico.andreoli@xxxxxxxxx>
>
> It turns out that there is one use case for programs being able to
> write to swap devices, and that is the userspace hibernation code.

You might want to start a separate thread for this... :)

Right

> Quick fix: disable the S_SWAPFILE check if hibernation is configured.
>
> Fixes: 1638045c3677 ("mm: set S_SWAPFILE on blockdev swap devices")

Also, this should be

Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files")

Of course

since we still want to set S_SWAPFILE on active swap devices.

> Reported-by: Domenico Andreoli <domenico.andreoli@xxxxxxxxx>
> Reported-by: Marian Klein <mkleinsoft@xxxxxxxxx>
> Signed-off-by: Domenico Andreoli <domenico.andreoli@xxxxxxxxx>
>
> ---
>  fs/block_dev.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> Index: b/fs/block_dev.c
> ===================================================================
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -2001,7 +2001,8 @@ ssize_t blkdev_write_iter(struct kiocb *
>       if (bdev_read_only(I_BDEV(bd_inode)))
>               return -EPERM;

> -     if (IS_SWAPFILE(bd_inode))
> +     /* uswsusp needs to write to the swap */
> +     if (IS_SWAPFILE(bd_inode) && !IS_ENABLED(CONFIG_HIBERNATION))

...&& hibernation_available() ?  That way we can configure this
dynamically.

Then it would just be "if (IS_SWAPFILE(bd_inode) && !hibernation_available())", right?

Thanks for taking this on, I'll go self-NAK the revert patch I sent
yesterday.
 
Thanks,
Dom

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux