Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp55264imu; Thu, 8 Nov 2018 14:41:37 -0800 (PST) X-Google-Smtp-Source: AJdET5cVfj4lbtGMUfHwareETdoxIpvDnyi0yllTZni59sWLSq+fARWTE0IwHmkg+hxfDhKFWH89 X-Received: by 2002:a63:e655:: with SMTP id p21mr5281184pgj.70.1541716896970; Thu, 08 Nov 2018 14:41:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716896; cv=none; d=google.com; s=arc-20160816; b=eHXttqK8rAOVKQbQkJCdxv5URJ1wLVH/Sf2hYBad1fUV6b4u0Zfk3rbVmnctriBJj1 eAUuyvlysW19ckywydSJjGYkGz2KHM/3yRV3yUFAO2Dq319eqEkTqXKAOv/Q6CF4nbx5 wg5p/YgllJna6EugCS58dHZZECiRyVvtnoMZugSvXIGRO1c7WJNtV7CTpSrz4cLtZXZv O+UOuSuREa/3Yf2U22/Oz/W/AATJ3la3z0UqlwPx0ODkrqj6k61Hax2uRv3Yte1ea1YL o9ldnNwPTzjDSljRWxtuq+kKMcDg0r/GWEQ3qjfZkuwW617J0uJFUgvEKDE7t4tXNMR4 wVAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kqbTpPuQdbTDKpRxzFCpKXxNBzfYPI+kP1aEtAm0VJ0=; b=rnLgFEPqylC3ZJEED14nquOIPrsZdnPpcve6XwWS40SeKqK7XwjfrmuvyRFhTjQgQC anSg/iHyXVYAj/BVCCwuVscUcEUmJjEL8X+EDHdkTscUVOd018YD4kMwbIIt+XPSo5wg Jq3m+7uVG2SsDGu5NIOcb4pfpxj2+HQhahZsiMLRYkipiGntwXz3M65TaC/LjqRTqKtf 2VyQKQe1n4CwfBDnVA5U6XAm1m/6ArNbggkcv530o7sdAsMQlAfZnilrtPHWX9IwFaqJ WVA/rYSctTAkcncGjMLbVS148l8zPAioaLefBim/QaICTbomaJB91dMIo//Dw2q/1FLJ fAaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aN4VcGnf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si5526885plm.136.2018.11.08.14.41.21; Thu, 08 Nov 2018 14:41:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aN4VcGnf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729081AbeKIHdn (ORCPT + 99 others); Fri, 9 Nov 2018 02:33:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:49794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729066AbeKIHdn (ORCPT ); Fri, 9 Nov 2018 02:33:43 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A1A0821104; Thu, 8 Nov 2018 21:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714175; bh=zy0wBWQZSp+DSESzmyU1yVbn7SjcLyLKV+klaklbx54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aN4VcGnfzSHBc9H0jTTiaCrpwoXhNBO4MMdlcqfVB4FxOvv11s1KskZN6hL3GPXiX vgivBmagPb3BAEQerd+wm8uLEkfS817TigebDdkg+oYnSGrfsNSWscQDU7572J1+1P gQsCVBbAdZ5wBBRUoMVqb5F+DgiugD+oaBAUIJvI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Carlos Carvalho , Jan Kara , Sasha Levin Subject: [PATCH 3.18 081/144] quota: Fix maximum quota limit settings Date: Thu, 8 Nov 2018 13:50:52 -0800 Message-Id: <20181108215101.225793829@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 7e08da50cf706151f324349f9235ebd311226997 ] Currently quota format that supports 64-bit usage sets maximum quota limit as 2^64-1. However quota core code uses signed numbers to track usage and even limits themselves are stored in long long. Checking of maximum allowable limits worked by luck until commit 14bf61ffe6ac (quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units) because variable we compared with was unsigned. After that commit the type we compared against changed to signed and thus checks for maximum limits with the newest VFS quota format started to refuse any non-negative value. Later the problem was inadvertedly fixed by commit b10a08194c2b (quota: Store maximum space limit in bytes) because we started to compare against unsigned type as well. Fix possible future problems of this kind by setting maximum limits to 2^63-1 to avoid overflow issues. Reported-by: Carlos Carvalho Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/quota/quota_v2.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c index d1a8054bba9a..5d9fc7918e24 100644 --- a/fs/quota/quota_v2.c +++ b/fs/quota/quota_v2.c @@ -117,12 +117,16 @@ static int v2_read_file_info(struct super_block *sb, int type) qinfo = info->dqi_priv; if (version == 0) { /* limits are stored as unsigned 32-bit data */ - info->dqi_max_spc_limit = 0xffffffffULL << QUOTABLOCK_BITS; + info->dqi_max_spc_limit = 0xffffffffLL << QUOTABLOCK_BITS; info->dqi_max_ino_limit = 0xffffffff; } else { - /* used space is stored as unsigned 64-bit value in bytes */ - info->dqi_max_spc_limit = 0xffffffffffffffffULL; /* 2^64-1 */ - info->dqi_max_ino_limit = 0xffffffffffffffffULL; + /* + * Used space is stored as unsigned 64-bit value in bytes but + * quota core supports only signed 64-bit values so use that + * as a limit + */ + info->dqi_max_spc_limit = 0x7fffffffffffffffLL; /* 2^63-1 */ + info->dqi_max_ino_limit = 0x7fffffffffffffffLL; } info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); -- 2.17.1