generic: check that we can't write to swap files
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 24 Sep 2019 16:39:37 +0000 (09:39 -0700)
committerEryu Guan <guaneryu@gmail.com>
Wed, 2 Oct 2019 10:51:16 +0000 (18:51 +0800)
commitdb8feee94964c23742ce503986531f58e35a5ea7
treec06d1252c1a838d6ba29d11cfd9cfbcf769c4af3
parent74f448265ac2a111283bacd1d0ad053377eb8b5d
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>
src/swapon.c
tests/generic/569 [new file with mode: 0755]
tests/generic/569.out [new file with mode: 0644]
tests/generic/570 [new file with mode: 0755]
tests/generic/570.out [new file with mode: 0644]
tests/generic/group