summaryrefslogtreecommitdiff
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-08-16 18:58:14 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2019-08-26 13:54:37 -0700
commit6501298adb79ad19f8b169add36d7a20e77d305e (patch)
tree5f5f7cd3826d92672196675a3a519599fbf85247 /mm/filemap.c
parent0c5f629377eba5a533c4802f8a281bee2a7539cb (diff)
vfs: don't allow writes to swap filesimmutable-swapfiles_2019-08-26
Don't let userspace write to an active swap file because the kernel effectively has a long term lease on the storage and things could get seriously corrupted if we let this happen. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index d0cf700bf201..40667c2f3383 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2988,6 +2988,9 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
loff_t count;
int ret;
+ if (IS_SWAPFILE(inode))
+ return -ETXTBSY;
+
if (!iov_iter_count(from))
return 0;