Commit 56939e01 authored by Domenico Andreoli's avatar Domenico Andreoli Committed by Darrick J. Wong

hibernate: Allow uswsusp to write to swap

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.

Quick fix: disable the S_SWAPFILE check if hibernation is configured.

Fixes: dc617f29 ("vfs: don't allow writes to swap files")
Reported-by: default avatarDomenico Andreoli <domenico.andreoli@linux.com>
Reported-by: default avatarMarian Klein <mkleinsoft@gmail.com>
Signed-off-by: default avatarDomenico Andreoli <domenico.andreoli@linux.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 98d54f81
......@@ -34,6 +34,7 @@
#include <linux/task_io_accounting_ops.h>
#include <linux/falloc.h>
#include <linux/uaccess.h>
#include <linux/suspend.h>
#include "internal.h"
struct bdev_inode {
......@@ -2001,7 +2002,8 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (bdev_read_only(I_BDEV(bd_inode)))
return -EPERM;
if (IS_SWAPFILE(bd_inode))
/* uswsusp needs write permission to the swap */
if (IS_SWAPFILE(bd_inode) && !hibernation_available())
return -ETXTBSY;
if (!iov_iter_count(from))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment