diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-20 15:21:45 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-28 10:57:53 -0700 |
commit | 67c2c5742599c5a0ebf4cb7413755ee89dee7d67 (patch) | |
tree | 20a0e5dd28332a95fcb97b44be0de35adb54d500 /mm/filemap.c | |
parent | 81268851da178edd33a099b1d178cc63cae27569 (diff) |
vfs: don't allow writes to swap filesimmutable-swapfiles_2019-06-28
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.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index dad85e10f5f8..fd80bc20e30a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2938,6 +2938,9 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) if (IS_IMMUTABLE(inode)) return -EPERM; + if (IS_SWAPFILE(inode)) + return -ETXTBSY; + if (!iov_iter_count(from)) return 0; |