diff options
author | Christoph Hellwig <hch@lst.de> | 2010-06-04 05:30:03 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:47:38 -0400 |
commit | db78b877f7744bec4a9d9f9e7d10da3931d7cd39 (patch) | |
tree | fd9ee2fbe0998218b6d90322f85b285887e6fe9d /mm/shmem.c | |
parent | 1025774ce411f2bd4b059ad7b53f0003569b74fa (diff) |
always call inode_change_ok early in ->setattr
Make sure we call inode_change_ok before doing any changes in ->setattr,
and make sure to call it even if our fs wants to ignore normal UNIX
permissions, but use the ATTR_FORCE to skip those.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 3b58ad65d26c..0a43505eeaec 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -767,6 +767,10 @@ static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) | |||
767 | loff_t newsize = attr->ia_size; | 767 | loff_t newsize = attr->ia_size; |
768 | int error; | 768 | int error; |
769 | 769 | ||
770 | error = inode_change_ok(inode, attr); | ||
771 | if (error) | ||
772 | return error; | ||
773 | |||
770 | if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE) | 774 | if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE) |
771 | && newsize != inode->i_size) { | 775 | && newsize != inode->i_size) { |
772 | struct page *page = NULL; | 776 | struct page *page = NULL; |
@@ -809,11 +813,9 @@ static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) | |||
809 | shmem_truncate_range(inode, newsize, (loff_t)-1); | 813 | shmem_truncate_range(inode, newsize, (loff_t)-1); |
810 | } | 814 | } |
811 | 815 | ||
812 | error = inode_change_ok(inode, attr); | 816 | setattr_copy(inode, attr); |
813 | if (!error) | ||
814 | setattr_copy(inode, attr); | ||
815 | #ifdef CONFIG_TMPFS_POSIX_ACL | 817 | #ifdef CONFIG_TMPFS_POSIX_ACL |
816 | if (!error && (attr->ia_valid & ATTR_MODE)) | 818 | if (attr->ia_valid & ATTR_MODE) |
817 | error = generic_acl_chmod(inode); | 819 | error = generic_acl_chmod(inode); |
818 | #endif | 820 | #endif |
819 | return error; | 821 | return error; |