Skip to contentSkip to conversation

quota: paranoia: check quota tree root

PATCH In review Konstantin Khlebnikov 2 participants 2 messages Feb 12, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 quota: paranoia: check quota tree root

Root level in quota tree must be already allocated otherwise this block could be used for something else.

---
 fs/quota/quota_tree.c |    7 +++++++
 1 file changed, 7 insertions(+)
fs/quota/quota_tree.c +7 -0
index d65877f..58efb83 100644
@@ -349,6 +349,13 @@ static inline int dq_insert_tree(struct qtree_mem_dqinfo *info,
 				 struct dquot *dquot)
 {
 	int tmp = QT_TREEOFF;
+
+#ifdef __QUOTA_QT_PARANOIA
+	if (info->dqi_blocks <= QT_TREEOFF) {
+		quota_error(dquot->dq_sb, "Quota tree root isn't allocated!");
+		return -EIO;
+	}
+#endif
 	return do_insert_tree(info, dquot, &tmp, 0);
 }
 
reviewer
#1 lore raw
Quoted 2 lines · Konstantin Khlebnikov

Root level in quota tree must be already allocated otherwise this block could be used for something else.

Thanks. I've added the patch to my tree.

Honza

Quoted 25 lines
---
 fs/quota/quota_tree.c |    7 +++++++
 1 file changed, 7 insertions(+)
fs/quota/quota_tree.c +7 -0
index d65877f..58efb83 100644
@@ -349,6 +349,13 @@ static inline int dq_insert_tree(struct qtree_mem_dqinfo *info,
 				 struct dquot *dquot)
 {
 	int tmp = QT_TREEOFF;
+
+#ifdef __QUOTA_QT_PARANOIA
+	if (info->dqi_blocks <= QT_TREEOFF) {
+		quota_error(dquot->dq_sb, "Quota tree root isn't allocated!");
+		return -EIO;
+	}
+#endif
 	return do_insert_tree(info, dquot, &tmp, 0);
 }
 
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR