Skip to contentSkip to conversation

ocfs2: fix potential use after free

PATCH New Pan Bian 1 participant 1 message Nov 25, 2018 OCFS2

lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 ocfs2: fix potential use after free

The function ocfs2_get_dentry calls iput(inode) to drop the reference count of inode, and if the reference count hits 0, inode is freed. However, in this function, it then reads inode->i_generation, which may result in a use after free bug. This patch moves the put operation later.

Fixes 781f200cb7a("ocfs2: Remove masklog ML_EXPORT.")
---
 fs/ocfs2/export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/export.c +1 -1
index 9f88188..4bf8d58 100644
@@ -125,10 +125,10 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,
 
 check_gen:
 	if (handle->ih_generation != inode->i_generation) {
-		iput(inode);
 		trace_ocfs2_get_dentry_generation((unsigned long long)blkno,
 						  handle->ih_generation,
 						  inode->i_generation);
+		iput(inode);
 		result = ERR_PTR(-ESTALE);
 		goto bail;
 	}
Signature · 1 line
2.7.4