Skip to contentSkip to conversation

quota: fix potential infinite loop

PATCH In review zhangyi (F) 2 participants 2 messages Nov 1, 2017

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

PATCH 1/1 quota: fix potential infinite loop

In dquot_writeback_dquots(), we write back dquot from dirty dquots list. There is a potential infinite loop if ->write_dquot() failure and forget remove dquot from the list. This patch clear dirty bit anyway to avoid it.

---
 fs/quota/dquot.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/quota/dquot.c +9 -2
index 52ad151..7ff0080 100644
@@ -644,8 +644,15 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
 			spin_unlock(&dq_list_lock);
 			dqstats_inc(DQST_LOOKUPS);
 			err = sb->dq_op->write_dquot(dquot);
-			if (!ret && err)
-				ret = err;
+			if (err) {
+				/*
+				 * Clear dirty bit anyway to avoid infinite
+				 * loop here.
+				 */
+				clear_dquot_dirty(dquot);
+				if (!ret)
+					ret = err;
+			}
 			dqput(dquot);
 			spin_lock(&dq_list_lock);
 		}
Signature · 1 line
2.9.5
reviewer
#1 lore raw
Quoted 6 lines · zhangyi (F)

In dquot_writeback_dquots(), we write back dquot from dirty dquots list. There is a potential infinite loop if ->write_dquot() failure and forget remove dquot from the list. This patch clear dirty bit anyway to avoid it.

Thanks. Added to my tree.

Honza

Quoted 29 lines
---
 fs/quota/dquot.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/quota/dquot.c +9 -2
index 52ad151..7ff0080 100644
@@ -644,8 +644,15 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
 			spin_unlock(&dq_list_lock);
 			dqstats_inc(DQST_LOOKUPS);
 			err = sb->dq_op->write_dquot(dquot);
-			if (!ret && err)
-				ret = err;
+			if (err) {
+				/*
+				 * Clear dirty bit anyway to avoid infinite
+				 * loop here.
+				 */
+				clear_dquot_dirty(dquot);
+				if (!ret)
+					ret = err;
+			}
 			dqput(dquot);
 			spin_lock(&dq_list_lock);
 		}
Signature · 1 line
2.9.5
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR