summaryrefslogtreecommitdiff
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-08-20 07:55:16 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2019-08-20 07:55:16 -0700
commitdc617f29dbe5ef0c8ced65ce62c464af1daaab3d (patch)
tree3596eb0d334f04f87088c735748bba8e66a71cad /mm/filemap.c
parent1638045c36772b47a0765f7dca07cb90267e4942 (diff)
vfs: don't allow writes to swap files
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> Reviewed-by: Christoph Hellwig <hch@lst.de>
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;