Skip to content

Commit 8179a10

Browse files
ukernelidryomov
authored andcommitted
ceph: fix recursion between ceph_set_acl() and __ceph_setattr()
ceph_set_acl() calls __ceph_setattr() if the setacl operation needs to modify inode's i_mode. __ceph_setattr() updates inode's i_mode, then calls posix_acl_chmod(). The problem is that __ceph_setattr() calls posix_acl_chmod() before sending the setattr request. The get_acl() call in posix_acl_chmod() can trigger a getxattr request. The reply of the getxattr request can restore inode's i_mode to its old value. The set_acl() call in posix_acl_chmod() sees old value of inode's i_mode, so it calls __ceph_setattr() again. Cc: [email protected] # needs backporting for < 4.9 Link: http://tracker.ceph.com/issues/19688 Reported-by: Jerry Lee <[email protected]> Signed-off-by: "Yan, Zheng" <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Tested-by: Luis Henriques <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 5a7ad11 commit 8179a10

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

fs/ceph/inode.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,11 +2071,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
20712071
if (inode_dirty_flags)
20722072
__mark_inode_dirty(inode, inode_dirty_flags);
20732073

2074-
if (ia_valid & ATTR_MODE) {
2075-
err = posix_acl_chmod(inode, attr->ia_mode);
2076-
if (err)
2077-
goto out_put;
2078-
}
20792074

20802075
if (mask) {
20812076
req->r_inode = inode;
@@ -2088,14 +2083,12 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
20882083
dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err,
20892084
ceph_cap_string(dirtied), mask);
20902085

2091-
ceph_mdsc_put_request(req);
2092-
if (mask & CEPH_SETATTR_SIZE)
2093-
__ceph_do_pending_vmtruncate(inode);
2094-
ceph_free_cap_flush(prealloc_cf);
2095-
return err;
2096-
out_put:
20972086
ceph_mdsc_put_request(req);
20982087
ceph_free_cap_flush(prealloc_cf);
2088+
2089+
if (err >= 0 && (mask & CEPH_SETATTR_SIZE))
2090+
__ceph_do_pending_vmtruncate(inode);
2091+
20992092
return err;
21002093
}
21012094

@@ -2114,7 +2107,12 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
21142107
if (err != 0)
21152108
return err;
21162109

2117-
return __ceph_setattr(inode, attr);
2110+
err = __ceph_setattr(inode, attr);
2111+
2112+
if (err >= 0 && (attr->ia_valid & ATTR_MODE))
2113+
err = posix_acl_chmod(inode, attr->ia_mode);
2114+
2115+
return err;
21182116
}
21192117

21202118
/*

0 commit comments

Comments
 (0)