From patchwork Thu Feb 12 09:36:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 5818561 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 18691BF440 for ; Thu, 12 Feb 2015 09:39:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B0BC20219 for ; Thu, 12 Feb 2015 09:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FF9C200C6 for ; Thu, 12 Feb 2015 09:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755441AbbBLJiN (ORCPT ); Thu, 12 Feb 2015 04:38:13 -0500 Received: from forward-corp1f.mail.yandex.net ([95.108.130.40]:41567 "EHLO forward-corp1f.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755403AbbBLJgw (ORCPT ); Thu, 12 Feb 2015 04:36:52 -0500 Received: from smtpcorp1m.mail.yandex.net (smtpcorp1m.mail.yandex.net [77.88.61.150]) by forward-corp1f.mail.yandex.net (Yandex) with ESMTP id 2EA4D24202E3; Thu, 12 Feb 2015 12:36:50 +0300 (MSK) Received: from smtpcorp1m.mail.yandex.net (localhost [127.0.0.1]) by smtpcorp1m.mail.yandex.net (Yandex) with ESMTP id E73602CA02DD; Thu, 12 Feb 2015 12:36:49 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:408:a4ea:72ba:f9d0:413c]) by smtpcorp1m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id V4zPWelMHN-anOKnvYA; Thu, 12 Feb 2015 12:36:49 +0300 (using TLSv1.2 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1423733809; bh=G2GEqF6I25kMVBbqUa2vFF3pjS+bIkErPH/jBM8sC+k=; h=Subject:From:To:Cc:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding; b=Tv2RWG+pKvuJ4PRtpvoOgsD75GGsyVoGOdTxC++IftkE1wC1JGSC4xeS49bBHceEO ZHllD24r4VH8VM7GMhJ9DBb/IaUXgkt1WiW2yDMQ/nSyiVglXvXLu7TreVnnJU4UHk 9hWtGm8pNy8TP93U71GTlHFpTJt9J8S0+LTbQwDM= Authentication-Results: smtpcorp1m.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH] quota: paranoia: check quota tree root From: Konstantin Khlebnikov To: linux-fsdevel@vger.kernel.org, Jan Kara Cc: linux-kernel@vger.kernel.org Date: Thu, 12 Feb 2015 12:36:49 +0300 Message-ID: <20150212093649.6117.62111.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Root level in quota tree must be already allocated otherwise this block could be used for something else. Signed-off-by: Konstantin Khlebnikov --- 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 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); }