+ vfs-partially-revert-dont-allow-writes-to-swap-files.patch added to -mm tree

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

 



The patch titled
     Subject: vfs: partially revert "don't allow writes to swap files"
has been added to the -mm tree.  Its filename is
     vfs-partially-revert-dont-allow-writes-to-swap-files.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/vfs-partially-revert-dont-allow-writes-to-swap-files.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/vfs-partially-revert-dont-allow-writes-to-swap-files.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
Subject: vfs: partially revert "don't allow writes to swap files"

In commit dc617f29dbe5 ("vfs: don't allow writes to swap files") we tried
to prevent userspace programs from writing to active swap devices. 
However, it turns out that userspace hibernation requires the ability to
write the hibernation image to a swap device, so revert the write path
checks.

Link: http://lkml.kernel.org/r/20200303191023.GD8037@magnolia
Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files")
Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
Reported-by: Domenico Andreoli <domenico.andreoli@xxxxxxxxx>
Reported-by: Marian Klein <mkleinsoft@xxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>
Cc: Len Brown <len.brown@xxxxxxxxx>
Cc: Pavel Machek <pavel@xxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 fs/block_dev.c |    3 ---
 mm/filemap.c   |    3 ---
 mm/memory.c    |    4 ----
 mm/mmap.c      |    8 ++------
 4 files changed, 2 insertions(+), 16 deletions(-)

--- a/fs/block_dev.c~vfs-partially-revert-dont-allow-writes-to-swap-files
+++ a/fs/block_dev.c
@@ -2001,9 +2001,6 @@ ssize_t blkdev_write_iter(struct kiocb *
 	if (bdev_read_only(I_BDEV(bd_inode)))
 		return -EPERM;
 
-	if (IS_SWAPFILE(bd_inode))
-		return -ETXTBSY;
-
 	if (!iov_iter_count(from))
 		return 0;
 
--- a/mm/filemap.c~vfs-partially-revert-dont-allow-writes-to-swap-files
+++ a/mm/filemap.c
@@ -2920,9 +2920,6 @@ inline ssize_t generic_write_checks(stru
 	loff_t count;
 	int ret;
 
-	if (IS_SWAPFILE(inode))
-		return -ETXTBSY;
-
 	if (!iov_iter_count(from))
 		return 0;
 
--- a/mm/memory.c~vfs-partially-revert-dont-allow-writes-to-swap-files
+++ a/mm/memory.c
@@ -2376,10 +2376,6 @@ static vm_fault_t do_page_mkwrite(struct
 
 	vmf->flags = FAULT_FLAG_WRITE|FAULT_FLAG_MKWRITE;
 
-	if (vmf->vma->vm_file &&
-	    IS_SWAPFILE(vmf->vma->vm_file->f_mapping->host))
-		return VM_FAULT_SIGBUS;
-
 	ret = vmf->vma->vm_ops->page_mkwrite(vmf);
 	/* Restore original flags so that caller is not surprised */
 	vmf->flags = old_flags;
--- a/mm/mmap.c~vfs-partially-revert-dont-allow-writes-to-swap-files
+++ a/mm/mmap.c
@@ -1461,12 +1461,8 @@ unsigned long do_mmap(struct file *file,
 		case MAP_SHARED_VALIDATE:
 			if (flags & ~flags_mask)
 				return -EOPNOTSUPP;
-			if (prot & PROT_WRITE) {
-				if (!(file->f_mode & FMODE_WRITE))
-					return -EACCES;
-				if (IS_SWAPFILE(file->f_mapping->host))
-					return -ETXTBSY;
-			}
+			if ((prot&PROT_WRITE) && !(file->f_mode&FMODE_WRITE))
+				return -EACCES;
 
 			/*
 			 * Make sure we don't allow writing to an append-only
_

Patches currently in -mm which might be from darrick.wong@xxxxxxxxxx are

vfs-partially-revert-dont-allow-writes-to-swap-files.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux