@@ -3670,6 +3670,12 @@ long ext4_fallocate(struct file *file, i
*/
credits = ext4_chunk_trans_blocks(inode, max_blocks);
mutex_lock(&inode->i_mutex);
+
+ if (IS_IMMUTABLE(inode)) {
+ mutex_unlock(&inode->i_mutex);
+ return -EPERM;
+ }
+
ret = inode_newsize_ok(inode, (len + offset));
if (ret) {
mutex_unlock(&inode->i_mutex);
@@ -1289,6 +1289,12 @@ static long btrfs_fallocate(struct file
btrfs_wait_ordered_range(inode, alloc_start, alloc_end - alloc_start);
mutex_lock(&inode->i_mutex);
+
+ if (IS_IMMUTABLE(inode)) {
+ ret = -EPERM;
+ goto out;
+ }
+
ret = inode_newsize_ok(inode, alloc_end);
if (ret)
goto out;
@@ -797,6 +797,11 @@ static long gfs2_fallocate(struct file *
if (unlikely(error))
goto out_uninit;
+ if (IS_IMMUTABLE(inode)) {
+ error = -EPERM;
+ goto out_unlock;
+ }
+
if (!gfs2_write_alloc_required(ip, offset, len))
goto out_unlock;
@@ -906,8 +906,18 @@ xfs_file_fallocate(
xfs_ilock(ip, XFS_IOLOCK_EXCL);
- if (mode & FALLOC_FL_PUNCH_HOLE)
+ if (mode & FALLOC_FL_PUNCH_HOLE) {
cmd = XFS_IOC_UNRESVSP;
+ if (IS_APPEND(inode)) {
+ error = -EPERM;
+ goto out_unlock;
+ }
+ }
+
+ if (IS_IMMUTABLE(inode)) {
+ error = -EPERM;
+ goto out_unlock;
+ }
/* check the new inode size is valid before allocating */
if (!(mode & FALLOC_FL_KEEP_SIZE) &&