Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1949982ima; Thu, 25 Oct 2018 07:27:38 -0700 (PDT) X-Google-Smtp-Source: AJdET5fXAXfkjC4LFOTv1cHVISigSw/lBvWbLV0ct7zivvsQyIlrmweeGrwwh5IRFVV0BOyXRf9G X-Received: by 2002:a62:4803:: with SMTP id v3-v6mr1841332pfa.89.1540477658506; Thu, 25 Oct 2018 07:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477658; cv=none; d=google.com; s=arc-20160816; b=Liol536z75Yx/xvdgEhLcfAsf0zvhOudBbV5DkkppNKA1R4ANuCO1rAqDJ+d/keEea VCIZf7qSt0t+w6NknYWOHID/ES0JxQouxM8OplvP5UIig4E21sAv5pi6obGNcMpBS3d8 WC5RHA5HSkOEQA8FkwaLZTXl+d5NHtCROQ7asxM4b72m0DhucRl1+X7WWbMCwdla/dfT 3+5NCTvC4H2ifFwenlbiG5xdiKCmrqrM09KK4KUWZ3AmUKMoQaV5gfEFz9bSOX8sV18z RGR2/GiDmMkQIg09fdcpJb+yzUxwIYsXe4igqTd+4SfZjlV8Qab0HeyI/gbEPOfS/UOB UWmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=vKMnqvLEBeFWfNGpqQmjNBerwj6knfhMXNzBDc3nLpQ=; b=0ax4zJO9yESpRC7HPNqhZsgjR/Mh6VSgtN9oU136FkI8k08eUUdm674lgJCAVNQfqS AqGe33NrRkoFbol2iXKnNkAp4JoJW+18r0FmeHiSynW/75MM8rH0S0p6re5aEmVHhLvJ DZbj0Fna0yDzXR+u2iNgTCJcYP3ZDBXzCNxUEK/TmeekFckLjDTlVebk4jV0GgvsBLyb fRgVdXWzluzGzmlH/1EQFnSIa4KzpeCdO3b60Oonf1IZVt1dj0zNKnbp/W9cy1hS0odG hBXGmQxj3sn0eHA51jkUMpmaApcNSWwaxVXs8CgcVaoefpmK0yLssET/apiTg0mtombe iNPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ASMGyFMR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s10-v6si3540639pgd.43.2018.10.25.07.26.42; Thu, 25 Oct 2018 07:27:38 -0700 (PDT) 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=ASMGyFMR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730922AbeJYWxM (ORCPT + 99 others); Thu, 25 Oct 2018 18:53:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:35580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730900AbeJYWxL (ORCPT ); Thu, 25 Oct 2018 18:53:11 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A39D32086D; Thu, 25 Oct 2018 14:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477213; bh=oAA2aeFnsMgprRsS3wlrSDHqHgBRopZPCwAr05t02QM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ASMGyFMRAxSVAZlLZcvCr4V5HYRum5fhuYrYUsKMotqhdMAfn+lOYn2xHTlmGt88M To9igaJ3ZxwfbgvfFlu6AegGJU6Meu2F911usdmkF+IoICjS2Tlh1nTLaVLXSjiOQx fL5oUpItyrD/yWdVpIVQ2l/+AHF5nCLstTd4+/DI= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jan Kara , Sasha Levin Subject: [PATCH AUTOSEL 3.18 52/98] quota: Fix maximum quota limit settings Date: Thu, 25 Oct 2018 10:18:07 -0400 Message-Id: <20181025141853.214051-52-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara [ 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