generic: check that we can't write to swap files

While active, the media backing a swap file is leased to the kernel.
Userspace has no business writing to it.  Make sure we can't do this.

The two kernel patches titled as below should fix the bug:

mm: set S_SWAPFILE on blockdev swap devices
vfs: don't allow writes to swap files

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Darrick J. Wong
2019-09-24 09:39:37 -07:00
committed by Eryu Guan
parent 74f448265a
commit db8feee949
6 changed files with 285 additions and 4 deletions
+12
View File
@@ -0,0 +1,12 @@
QA output created by 570
verb 1
pwrite: Text file busy
verb 2
mmap: Text file busy
verb 3
Caught signal 7, terminating...
verb 4
pwrite: Text file busy
pwrite: Text file busy
mmap: Text file busy
no mapped regions, try 'help mmap'