diff options
author | Domenico Andreoli <domenico.andreoli@linux.com> | 2020-03-23 18:22:15 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-23 11:38:09 +0300 |
commit | b8bc5e7511bc98ea4ad76e5b3ecd9092ccb16535 (patch) | |
tree | 7a9906f30a4624f017d5a9953bf8b996dd63ba45 | |
parent | 99d3ff43fc502bf08ca74bdce059c72009b1bac3 (diff) | |
download | linux-b8bc5e7511bc98ea4ad76e5b3ecd9092ccb16535.tar.xz |
hibernate: Allow uswsusp to write to swap
[ Upstream commit 56939e014a6c212b317414faa307029e2e80c3b9 ]
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: dc617f29dbe5 ("vfs: don't allow writes to swap files")
Reported-by: Domenico Andreoli <domenico.andreoli@linux.com>
Reported-by: Marian Klein <mkleinsoft@gmail.com>
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | fs/block_dev.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 69bf2fb6f7cd..84fe0162ff13 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -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)) |