FAILED: patch "[PATCH] ceph: fix recursion between ceph_set_acl() and" failed to apply to 4.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
8179a101eb5f4ef0ac9a915fcea9a9d3109efa90Mon Sep 17 00:00:00 2001
From: "Yan, Zheng" <[email protected]>
Date: Wed, 19 Apr 2017 10:01:48 +0800
Subject: [PATCH] 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.
fs/ceph/inode.c +10 -12
@@ -2071,11 +2071,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)if (inode_dirty_flags)__mark_inode_dirty (inode, inode_dirty_flags); -if (ia_valid &ATTR_MODE ) { - err =posix_acl_chmod (inode, attr->ia_mode); -if (err) - goto out_put; - }if (mask) { req->r_inode = inode;
@@ -2089,13 +2084,11 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) ceph_cap_string(dirtied), mask);ceph_mdsc_put_request (req); -if (mask &CEPH_SETATTR_SIZE ) -__ceph_do_pending_vmtruncate (inode); -ceph_free_cap_flush (prealloc_cf); -return err; -out_put: -ceph_mdsc_put_request (req);ceph_free_cap_flush (prealloc_cf); + +if (err >=0 && (mask &CEPH_SETATTR_SIZE )) +__ceph_do_pending_vmtruncate (inode); +return err; }
@@ -2114,7 +2107,12 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)if (err !=0 )return err; -return __ceph_setattr (inode, attr); + err =__ceph_setattr (inode, attr); + +if (err >=0 && (attr->ia_valid &ATTR_MODE )) + err =posix_acl_chmod (inode, attr->ia_mode); + +return err; }/*
Quoted 6 lines · Greg Kroah-Hartman
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Here's a backport I've tested with 4.4.
Cheers,
--
Lu�s
Quoted 1 line
From
beab414f9df0c865e73e651393538cde1fa20a3dMon Sep 17 00:00:00 2001
From: "Yan, Zheng" <[email protected]>
Date: Wed, 19 Apr 2017 10:01:48 +0800
Subject: [PATCH] ceph: fix recursion between ceph_set_acl() and
__ceph_setattr()
commit 8179a101eb5f4ef0ac9a915fcea9a9d3109efa90 upstream.
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.
[luis: __ceph_setattr doesn't exist in 4.4, implement all the changes
directly in ceph_setattr. The wrapper function was introduced only in commit a26feccaba29 ("ceph: Get rid of d_find_alias in ceph_set_acl").]
--- fs/ceph/inode.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
fs/ceph/inode.c +7 -11
@@ -1975,11 +1975,6 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)if (inode_dirty_flags)__mark_inode_dirty (inode, inode_dirty_flags); -if (ia_valid &ATTR_MODE ) { - err =posix_acl_chmod (inode, attr->ia_mode); -if (err) - goto out_put; - }if (mask) { req->r_inode = inode;
@@ -1993,13 +1988,14 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) ceph_cap_string(dirtied), mask);ceph_mdsc_put_request (req); -if (mask &CEPH_SETATTR_SIZE ) -__ceph_do_pending_vmtruncate (inode); -ceph_free_cap_flush (prealloc_cf); -return err; -out_put: -ceph_mdsc_put_request (req);ceph_free_cap_flush (prealloc_cf); + +if (err >=0 && (mask &CEPH_SETATTR_SIZE )) +__ceph_do_pending_vmtruncate (inode); + +if (err >=0 && (attr->ia_valid &ATTR_MODE )) + err =posix_acl_chmod (inode, attr->ia_mode); +return err; }
Quoted 77 lines · Luis Henriques
Quoted 6 lines · Greg Kroah-Hartman
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.Here's a backport I've tested with 4.4.
Cheers,
--
LuísFrom
beab414f9df0c865e73e651393538cde1fa20a3dMon Sep 17 00:00:00 2001
From: "Yan, Zheng" <[email protected]>
Date: Wed, 19 Apr 2017 10:01:48 +0800
Subject: [PATCH] ceph: fix recursion betweenceph_set_acl()and__ceph_setattr()commit
8179a101eb5f4ef0ac9a915fcea9a9d3109efa90upstream.
ceph_set_acl()calls__ceph_setattr()if the setacl operation needs to modify inode'si_mode.__ceph_setattr()updates inode'si_mode, then callsposix_acl_chmod().The problem is that
__ceph_setattr()callsposix_acl_chmod()before sending the setattr request. Theget_acl()call inposix_acl_chmod()can trigger a getxattr request. The reply of the getxattr request can restore inode'si_modeto its old value. Theset_acl()call inposix_acl_chmod()sees old value of inode'si_mode, so it calls__ceph_setattr()again.Cc [email protected] # needs backporting for < 4.9Reported-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]>[luis:
__ceph_setattrdoesn't exist in 4.4, implement all the changes directly inceph_setattr. The wrapper function was introduced only in commita26feccaba29("ceph: Get rid ofd_find_aliasinceph_set_acl").]Signed-off-by Luis Henriques <[email protected]>---
fs/ceph/inode.c| 18 +++++++-----------1 file changed, 7 insertions(+), 11 deletions(-)fs/ceph/inode.c +0
-11@@ -1975,11 +1975,6 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)if (inode_dirty_flags)__mark_inode_dirty (inode, inode_dirty_flags); -if (ia_valid &ATTR_MODE ) { - err =posix_acl_chmod (inode, attr->ia_mode); -if (err) - goto out_put; - }if (mask) { req->r_inode = inode;@@ -1993,13 +1988,14 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) ceph_cap_string(dirtied), mask);ceph_mdsc_put_request (req); -if (mask &CEPH_SETATTR_SIZE ) -__ceph_do_pending_vmtruncate (inode); -ceph_free_cap_flush (prealloc_cf); -return err; -out_put: -ceph_mdsc_put_request (req);
fs/ceph/inode.c int ceph_setattr(struct dentry *dentry, struct iattr *attr) · line 2000
Quoted 10 lines
fs/ceph/inode.c +7
-0ceph_free_cap_flush (prealloc_cf); + +if (err >=0 && (mask &CEPH_SETATTR_SIZE )) +__ceph_do_pending_vmtruncate (inode); + +if (err >=0 && (attr->ia_valid &ATTR_MODE )) + err =posix_acl_chmod (inode, attr->ia_mode); +return err; }
Thank you for the patch. but it does not work because ceph_set_acl() calls ceph_setattr() directly. I think we need to introduce __ceph_setattr() and make ceph_set_acl() call __ceph_setattr()
Regards
Yan, Zheng
On Tue, May 02, 2017 at 07:19:06PM +0800, Yan, Zheng wrote:
[...]
Quoted 3 lines
Thank you for the patch. but it does not work because
ceph_set_acl()callsceph_setattr()directly. I think we need to introduce__ceph_setattr()and makeceph_set_acl()call__ceph_setattr()
Ah, of course! Maybe something like this:
Quoted 1 line
From
a6751ca41e6096638b75bf9d066338571399e8b4Mon Sep 17 00:00:00 2001
From: "Yan, Zheng" <[email protected]>
Date: Wed, 19 Apr 2017 10:01:48 +0800
Subject: [PATCH] ceph: fix recursion between ceph_set_acl() and
__ceph_setattr()
commit 8179a101eb5f4ef0ac9a915fcea9a9d3109efa90 upstream.
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.
[luis: introduce __ceph_setattr() and make ceph_set_acl() call it, as
suggested by Yan.]
--- fs/ceph/acl.c | 4 ++-- fs/ceph/inode.c | 27 ++++++++++++++++----------- fs/ceph/super.h | 1 + 3 files changed, 19 insertions(+), 13 deletions(-)
fs/ceph/acl.c +2 -2
@@ -128,7 +128,7 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)if (new_mode != old_mode) { newattrs.ia_mode = new_mode; newattrs.ia_valid =ATTR_MODE ; - ret =ceph_setattr (dentry, &newattrs); + ret =__ceph_setattr (dentry, &newattrs);if (ret) goto out_dput; }
@@ -138,7 +138,7 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)if (new_mode != old_mode) { newattrs.ia_mode = old_mode; newattrs.ia_valid =ATTR_MODE ; -ceph_setattr (dentry, &newattrs); +__ceph_setattr (dentry, &newattrs); } goto out_dput; }
fs/ceph/inode.c +16 -11
@@ -1773,7 +1773,7 @@ static const struct inode_operations ceph_symlink_iops = {/* * setattr */ -int ceph_setattr (struct dentry *dentry,struct iattr *attr) +int __ceph_setattr (struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);struct ceph_inode_info *ci =ceph_inode (inode);
@@ -1975,11 +1975,6 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)if (inode_dirty_flags)__mark_inode_dirty (inode, inode_dirty_flags); -if (ia_valid &ATTR_MODE ) { - err =posix_acl_chmod (inode, attr->ia_mode); -if (err) - goto out_put; - }if (mask) { req->r_inode = inode;
@@ -1993,13 +1988,23 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) ceph_cap_string(dirtied), mask);ceph_mdsc_put_request (req); -if (mask &CEPH_SETATTR_SIZE ) -__ceph_do_pending_vmtruncate (inode);ceph_free_cap_flush (prealloc_cf); + +if (err >=0 && (mask &CEPH_SETATTR_SIZE )) +__ceph_do_pending_vmtruncate (inode); +return err; -out_put: -ceph_mdsc_put_request (req); -ceph_free_cap_flush (prealloc_cf); +} + +int ceph_setattr (struct dentry *dentry,struct iattr *attr) +{ +int err; + + err =__ceph_setattr (dentry, attr); + +if (err >=0 && (attr->ia_valid &ATTR_MODE )) + err =posix_acl_chmod (d_inode (dentry), attr->ia_mode); +return err; }
fs/ceph/super.h +1 -0
@@ -788,6 +788,7 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)return __ceph_do_getattr (inode,NULL , mask, force); }extern int ceph_permission (struct inode *inode,int mask); +extern int __ceph_setattr (struct dentry *dentry,struct iattr *attr);extern int ceph_setattr (struct dentry *dentry,struct iattr *attr);extern int ceph_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat);
Yan, Zheng
Reviewed-byQuoted 128 lines · Luis Henriques
On Tue, May 02, 2017 at 07:19:06PM +0800, Yan, Zheng wrote:
[...]Quoted 3 lines
Thank you for the patch. but it does not work because
ceph_set_acl()callsceph_setattr()directly. I think we need to introduce__ceph_setattr()and makeceph_set_acl()call__ceph_setattr()Ah, of course! Maybe something like this:
From
a6751ca41e6096638b75bf9d066338571399e8b4Mon Sep 17 00:00:00 2001
From: "Yan, Zheng" <[email protected]>
Date: Wed, 19 Apr 2017 10:01:48 +0800
Subject: [PATCH] ceph: fix recursion betweenceph_set_acl()and__ceph_setattr()commit
8179a101eb5f4ef0ac9a915fcea9a9d3109efa90upstream.
ceph_set_acl()calls__ceph_setattr()if the setacl operation needs to modify inode'si_mode.__ceph_setattr()updates inode'si_mode, then callsposix_acl_chmod().The problem is that
__ceph_setattr()callsposix_acl_chmod()before sending the setattr request. Theget_acl()call inposix_acl_chmod()can trigger a getxattr request. The reply of the getxattr request can restore inode'si_modeto its old value. Theset_acl()call inposix_acl_chmod()sees old value of inode'si_mode, so it calls__ceph_setattr()again.Cc [email protected] # needs backporting for < 4.9Reported-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]>[luis: introduce
__ceph_setattr()and makeceph_set_acl()call it, as suggested by Yan.]Signed-off-by Luis Henriques <[email protected]>---
fs/ceph/acl.c | 4 ++-- fs/ceph/inode.c | 27 ++++++++++++++++----------- fs/ceph/super.h | 1 + 3 files changed, 19 insertions(+), 13 deletions(-)fs/ceph/acl.c +2
-2@@ -128,7 +128,7 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)if (new_mode != old_mode) { newattrs.ia_mode = new_mode; newattrs.ia_valid =ATTR_MODE ; - ret =ceph_setattr (dentry, &newattrs); + ret =__ceph_setattr (dentry, &newattrs);if (ret) goto out_dput; }@@ -138,7 +138,7 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)if (new_mode != old_mode) { newattrs.ia_mode = old_mode; newattrs.ia_valid =ATTR_MODE ; -ceph_setattr (dentry, &newattrs); +__ceph_setattr (dentry, &newattrs); } goto out_dput; }fs/ceph/inode.c +16
-11@@ -1773,7 +1773,7 @@ static const struct inode_operations ceph_symlink_iops = {/* * setattr */ -int ceph_setattr (struct dentry *dentry,struct iattr *attr) +int __ceph_setattr (struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);struct ceph_inode_info *ci =ceph_inode (inode);@@ -1975,11 +1975,6 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)if (inode_dirty_flags)__mark_inode_dirty (inode, inode_dirty_flags); -if (ia_valid &ATTR_MODE ) { - err =posix_acl_chmod (inode, attr->ia_mode); -if (err) - goto out_put; - }if (mask) { req->r_inode = inode;@@ -1993,13 +1988,23 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) ceph_cap_string(dirtied), mask);ceph_mdsc_put_request (req); -if (mask &CEPH_SETATTR_SIZE ) -__ceph_do_pending_vmtruncate (inode);ceph_free_cap_flush (prealloc_cf); + +if (err >=0 && (mask &CEPH_SETATTR_SIZE )) +__ceph_do_pending_vmtruncate (inode); +return err; -out_put: -ceph_mdsc_put_request (req); -ceph_free_cap_flush (prealloc_cf); +} + +int ceph_setattr (struct dentry *dentry,struct iattr *attr) +{ +int err; + + err =__ceph_setattr (dentry, attr); + +if (err >=0 && (attr->ia_valid &ATTR_MODE )) + err =posix_acl_chmod (d_inode (dentry), attr->ia_mode); +return err; }fs/ceph/super.h +0
-0
fs/ceph/super.h static inline int ceph_do_getattr(struct inode *inode, int mask, bool force) · line 794
Quoted 7 lines
fs/ceph/super.h +1
-0@@ -788,6 +788,7 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)return __ceph_do_getattr (inode,NULL , mask, force); }extern int ceph_permission (struct inode *inode,int mask); +extern int __ceph_setattr (struct dentry *dentry,struct iattr *attr);extern int ceph_setattr (struct dentry *dentry,struct iattr *attr);extern int ceph_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat);