diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-06-09 23:20:34 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-09-15 20:30:53 +0300 |
commit | 91e39600bf8a89d392a092448cb509caa1645bc0 (patch) | |
tree | c9c1dd295c9e4a9749ad628eca861ec20c3c4617 | |
parent | 981b726802cc71b54d67ab48804321a6a64e1907 (diff) | |
download | linux-91e39600bf8a89d392a092448cb509caa1645bc0.tar.xz |
excessive checks in ufs_write_failed() and ufs_evict_inode()
commit babef37dccbaa49249a22bae9150686815d7be71 upstream.
As it is, short copy in write() to append-only file will fail
to truncate the excessive allocated blocks. As the matter of
fact, all checks in ufs_truncate_blocks() are either redundant
or wrong for that caller. As for the only other caller
(ufs_evict_inode()), we only need the file type checks there.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[bwh: Backported to 3.2:
- No functions need to be renamed
- Adjust filenames, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | fs/ufs/inode.c | 5 | ||||
-rw-r--r-- | fs/ufs/truncate.c | 6 |
2 files changed, 4 insertions, 7 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 879b13436fa4..56947d3e0e68 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -890,7 +890,10 @@ void ufs_evict_inode(struct inode * inode) ufs_update_inode(inode, IS_SYNC(inode)); old_i_size = inode->i_size; inode->i_size = 0; - if (inode->i_blocks && ufs_truncate(inode, old_i_size)) + if (inode->i_blocks && + (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || + S_ISLNK(inode->i_mode)) && + ufs_truncate(inode, old_i_size)) ufs_warning(inode->i_sb, __func__, "ufs_truncate failed\n"); unlock_ufs(inode->i_sb); } diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c index 92cde998aead..93bc59c0d598 100644 --- a/fs/ufs/truncate.c +++ b/fs/ufs/truncate.c @@ -451,12 +451,6 @@ int ufs_truncate(struct inode *inode, loff_t old_i_size) inode->i_ino, (unsigned long long)i_size_read(inode), (unsigned long long)old_i_size); - if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || - S_ISLNK(inode->i_mode))) - return -EINVAL; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) - return -EPERM; - err = ufs_alloc_lastblock(inode); if (err) { |