Skip to contentSkip to conversation

Fix recent use-after-free spotted by coverity

PATCH New Bob Peterson 2 participants 2 messages Jan 6, 2012 – Jan 9, 2012 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 8a91332c-d06e-4a6a-9672-dcd2ebe261f6@zmail16.collab.prod.int.phx2.redhat.com

#1 lore raw

PATCH 1/1 Fix recent use-after-free spotted by coverity

Hi,

This patch fixes a use-after-free bug, spotted by coverity, which was recently introduced.

Regards,

Bob Peterson
Red Hat File Systems

--

Author: Bob Peterson <[email protected]>
Date:   Fri Jan 6 16:42:27 2012 -0600

GFS2: Fix a use-after-free that coverity spotted

In function gfs2_inplace_release it was trying to unlock a gfs2_holder structure associated with a reservation, after said reservation was freed. The problem is that the statements have the wrong order. This patch corrects the order so that the reservation is freed after the gfs2_holder is unlocked.

fs/gfs2/rgrp.c +1 -1
index 2223462..981bfa3 100644
@@ -1108,9 +1108,9 @@ void gfs2_inplace_release(struct gfs2_inode *ip)
 {
 	struct gfs2_blkreserv *rs = ip->i_res;
 
-	gfs2_blkrsv_put(ip);
 	if (rs->rs_rgd_gh.gh_gl)
 		gfs2_glock_dq_uninit(&rs->rs_rgd_gh);
+	gfs2_blkrsv_put(ip);
 }
 
 /**
#2 lore raw

PATCH 1/1 Fix recent use-after-free spotted by coverity

Hi,

Now in the -fixes tree. Thanks,

Steve.

Quoted 39 lines · Bob Peterson

Hi,

This patch fixes a use-after-free bug, spotted by coverity, which was recently introduced.

Regards,

Bob Peterson
Red Hat File Systems

--

Author: Bob Peterson <[email protected]>
Date:   Fri Jan 6 16:42:27 2012 -0600

GFS2: Fix a use-after-free that coverity spotted

In function gfs2_inplace_release it was trying to unlock a gfs2_holder structure associated with a reservation, after said reservation was freed. The problem is that the statements have the wrong order. This patch corrects the order so that the reservation is freed after the gfs2_holder is unlocked.

fs/gfs2/rgrp.c +1 -1
index 2223462..981bfa3 100644
@@ -1108,9 +1108,9 @@ void gfs2_inplace_release(struct gfs2_inode *ip)
 {
 	struct gfs2_blkreserv *rs = ip->i_res;
 
-	gfs2_blkrsv_put(ip);
 	if (rs->rs_rgd_gh.gh_gl)
 		gfs2_glock_dq_uninit(&rs->rs_rgd_gh);
+	gfs2_blkrsv_put(ip);
 }
 
 /**