mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
hibernate: Allow uswsusp to write to swap
[ Upstream commit56939e014a] 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:dc617f29db("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4753b111f0
commit
285f25c97f
@@ -34,6 +34,7 @@
|
|||||||
#include <linux/task_io_accounting_ops.h>
|
#include <linux/task_io_accounting_ops.h>
|
||||||
#include <linux/falloc.h>
|
#include <linux/falloc.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
#include <linux/suspend.h>
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
struct bdev_inode {
|
struct bdev_inode {
|
||||||
@@ -1975,7 +1976,8 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
|
|||||||
if (bdev_read_only(I_BDEV(bd_inode)))
|
if (bdev_read_only(I_BDEV(bd_inode)))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (IS_SWAPFILE(bd_inode))
|
/* uswsusp needs write permission to the swap */
|
||||||
|
if (IS_SWAPFILE(bd_inode) && !hibernation_available())
|
||||||
return -ETXTBSY;
|
return -ETXTBSY;
|
||||||
|
|
||||||
if (!iov_iter_count(from))
|
if (!iov_iter_count(from))
|
||||||
|
|||||||
Reference in New Issue
Block a user