aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-05-26 10:10:38 -0400
committerJan Kara <jack@suse.cz>2016-09-22 04:56:19 -0400
commitfd5472ed44683cf593322a2ef54b9a7675dc780a (patch)
tree24e1f8a7fa4a0ec32e88d8c3a28ab43bcd131b97
parent69bca80744eef58fa155e8042996b968fec17b26 (diff)
ceph: Propagate dentry down to inode_change_ok()
To avoid clearing of capabilities or security related extended attributes too early, inode_change_ok() will need to take dentry instead of inode. ceph_setattr() has the dentry easily available but __ceph_setattr() is also called from ceph_set_acl() where dentry is not easily available. Luckily that call path does not need inode_change_ok() to be called anyway. So reorganize functions a bit so that inode_change_ok() is called only from paths where dentry is available. Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/ceph/acl.c5
-rw-r--r--fs/ceph/inode.c19
2 files changed, 16 insertions, 8 deletions
diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index d0b6b342dff9..987044bca1c2 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -125,6 +125,11 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
125 goto out_free; 125 goto out_free;
126 } 126 }
127 127
128 if (ceph_snap(inode) != CEPH_NOSNAP) {
129 ret = -EROFS;
130 goto out_free;
131 }
132
128 if (new_mode != old_mode) { 133 if (new_mode != old_mode) {
129 newattrs.ia_mode = new_mode; 134 newattrs.ia_mode = new_mode;
130 newattrs.ia_valid = ATTR_MODE; 135 newattrs.ia_valid = ATTR_MODE;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index dd3a6dbf71eb..2aa3c0bcf3a5 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1905,13 +1905,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
1905 int inode_dirty_flags = 0; 1905 int inode_dirty_flags = 0;
1906 bool lock_snap_rwsem = false; 1906 bool lock_snap_rwsem = false;
1907 1907
1908 if (ceph_snap(inode) != CEPH_NOSNAP)
1909 return -EROFS;
1910
1911 err = inode_change_ok(inode, attr);
1912 if (err != 0)
1913 return err;
1914
1915 prealloc_cf = ceph_alloc_cap_flush(); 1908 prealloc_cf = ceph_alloc_cap_flush();
1916 if (!prealloc_cf) 1909 if (!prealloc_cf)
1917 return -ENOMEM; 1910 return -ENOMEM;
@@ -2124,7 +2117,17 @@ out_put:
2124 */ 2117 */
2125int ceph_setattr(struct dentry *dentry, struct iattr *attr) 2118int ceph_setattr(struct dentry *dentry, struct iattr *attr)
2126{ 2119{
2127 return __ceph_setattr(d_inode(dentry), attr); 2120 struct inode *inode = d_inode(dentry);
2121 int err;
2122
2123 if (ceph_snap(inode) != CEPH_NOSNAP)
2124 return -EROFS;
2125
2126 err = inode_change_ok(inode, attr);
2127 if (err != 0)
2128 return err;
2129
2130 return __ceph_setattr(inode, attr);
2128} 2131}
2129 2132
2130/* 2133/*