gfs2: get rid of potential double free
PATCH 1/1 gfs2: get rid of potential double free
__gfs2_set_acl will not increase the reference count of acl if it fails. In this case, posix_acl_release are called twice, one after __gfs2_set_acl and one in the error handling block. This patch does not release acl when __gfs2_set_acl fails.
--- fs/gfs2/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/gfs2/inode.c +5 -4
@@ -744,12 +744,13 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,the gfs2 structures. */ if (default_acl) { error =__gfs2_set_acl (inode, default_acl,ACL_TYPE_DEFAULT ); -posix_acl_release (default_acl); +if (!error) +posix_acl_release (default_acl); } -if (acl) { +if (acl && !error) { + error =__gfs2_set_acl (inode, acl,ACL_TYPE_ACCESS );if (!error) - error =__gfs2_set_acl (inode, acl,ACL_TYPE_ACCESS ); -posix_acl_release (acl); +posix_acl_release (acl); }if (error)
Signature · 1 line
2.7.4
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: get rid of potential double free
Pan,
Quoted 5 lines · Pan Bian
__gfs2_set_aclwill not increase the reference count of acl if it fails. In this case,posix_acl_releaseare called twice, one after__gfs2_set_acland one in the error handling block. This patch does not release acl when__gfs2_set_aclfails.
thanks for the bug report and patch; I think this should be fixed more clearly as in the patch I've posted earlier today.
Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20181127/ade5008f/attachment.htm>
Quoted 4 lines · Andreas Gruenbacher
Pan,
On Mon, 26 Nov 2018 at 09:44, Pan Bian <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
__gfs2_set_aclwill not increase the reference count of acl if it fails. In this case,posix_acl_releaseare called twice, one after__gfs2_set_acland one in the error handling block. This patch does not release acl when__gfs2_set_aclfails.thanks for the bug report and patch; I think this should be fixed more clearly as in the patch I've posted earlier today.
I have seen the patch. It is really much clearer. Thank you!
Pan
Quoted 2 lines
Andreas