diff mbox

quota: paranoia: check quota tree root

Message ID 20150212093649.6117.62111.stgit@buzz (mailing list archive)
State New, archived
Headers show

Commit Message

Konstantin Khlebnikov Feb. 12, 2015, 9:36 a.m. UTC
Root level in quota tree must be already allocated otherwise this block
could be used for something else.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 fs/quota/quota_tree.c |    7 +++++++
 1 file changed, 7 insertions(+)


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jan Kara Feb. 12, 2015, 2:04 p.m. UTC | #1
On Thu 12-02-15 12:36:49, Konstantin Khlebnikov wrote:
> 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

> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
>  fs/quota/quota_tree.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
> index d65877f..58efb83 100644
> --- a/fs/quota/quota_tree.c
> +++ b/fs/quota/quota_tree.c
> @@ -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);
>  }
>  
>
diff mbox

Patch

diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
index d65877f..58efb83 100644
--- a/fs/quota/quota_tree.c
+++ b/fs/quota/quota_tree.c
@@ -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);
 }