Skip to contentSkip to conversation

ocfs2: add extra consistency checks for chain allocator dinodes

PATCH In review Changjian Liu 2 participants 2 messages Mar 29 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: add extra consistency checks for chain allocator dinodes

[ Upstream commit e1c70505ee8158c1108340d9cd67182ade93af4a ]

ocfs2: add extra consistency checks for chain allocator dinodes

When validating chain allocator dinode in 'ocfs2_validate_inode_block()', add an extra checks whether a) the maximum amount of chain records in 'struct ocfs2_chain_list' matches the value calculated based on the filesystem block size, and b) the next free slot index is within the valid range.

---
 fs/ocfs2/inode.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
fs/ocfs2/inode.c +17 -0
index c561a8a6493e..7c99f436037b 100644
@@ -1419,6 +1419,23 @@ int ocfs2_validate_inode_block(struct super_block *sb,
 		goto bail;
 	}
 
+	if (le32_to_cpu(di->i_flags) & OCFS2_CHAIN_FL) {
+		struct ocfs2_chain_list *cl = &di->id2.i_chain;
+
+		if (le16_to_cpu(cl->cl_count) != ocfs2_chain_recs_per_inode(sb)) {
+			rc = ocfs2_error(sb, "Invalid dinode %llu: chain list count %u\n",
+					 (unsigned long long)bh->b_blocknr,
+					 le16_to_cpu(cl->cl_count));
+			goto bail;
+		}
+		if (le16_to_cpu(cl->cl_next_free_rec) > le16_to_cpu(cl->cl_count)) {
+			rc = ocfs2_error(sb, "Invalid dinode %llu: chain list index %u\n",
+					 (unsigned long long)bh->b_blocknr,
+					 le16_to_cpu(cl->cl_next_free_rec));
+			goto bail;
+		}
+	}
+
 	rc = 0;
 
 bail:
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 3 lines · Changjian Liu

[ Upstream commit e1c70505ee8158c1108340d9cd67182ade93af4a ]

ocfs2: add extra consistency checks for chain allocator dinodes

For some reason you did not address my previous review comments, so I'm going to have to delete this and ignore future submissions until you work with someone who can help you with the development process and will submit changes that they have approved first.

sorry,

greg k-h