diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-20 07:55:16 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-20 07:55:16 -0700 |
commit | dc617f29dbe5ef0c8ced65ce62c464af1daaab3d (patch) | |
tree | 3596eb0d334f04f87088c735748bba8e66a71cad /fs/block_dev.c | |
parent | 1638045c36772b47a0765f7dca07cb90267e4942 (diff) | |
download | lwn-dc617f29dbe5ef0c8ced65ce62c464af1daaab3d.tar.gz lwn-dc617f29dbe5ef0c8ced65ce62c464af1daaab3d.zip |
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 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index c2a85b587922..d9bab63a9b81 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1978,6 +1978,9 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) if (bdev_read_only(I_BDEV(bd_inode))) return -EPERM; + if (IS_SWAPFILE(bd_inode)) + return -ETXTBSY; + if (!iov_iter_count(from)) return 0; |