fs: disallow all fallocate operation on active swapfile

Currently some file system have IS_SWAPFILE check in their fallocate
implementations and some do not. However we should really prevent any
fallocate operation on swapfile so move the check to vfs and remove the
redundant checks from the file systems fallocate implementations.

Signed-off-by: Lukas Czerner <[email protected]>
Signed-off-by: "Theodore Ts'o" <[email protected]>
This commit is contained in:
Lukas Czerner 2014-04-12 10:05:37 -04:00 • committed by Theodore Ts'o
commit 0790b31b69
4 changed files with 7 additions and 13 deletions

View file

@ -262,6 +262,13 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
if (IS_IMMUTABLE(inode))
return -EPERM;
/*
* We can not allow to do any fallocate operation on an active
* swapfile
*/
if (IS_SWAPFILE(inode))
ret = -ETXTBSY;
/*
* Revalidate the write permissions, in case security policy has
* changed since the files were opened.