From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4638A6FBB for ; Tue, 10 Jan 2023 18:29:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83BF0C433F1; Tue, 10 Jan 2023 18:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673375355; bh=dNweg9gLYY23OzHIyP+bnl51BtkA7TINswQJsDt5y2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l3HxOtgTP1kmx/cUjR2m0aAqjYsHr7aMIu8VdfXuaEMLn7psjC1hV8tVVr61UeLwF J8KfZSluUIrvqk8PKBRlT1OjL9k+TBZK8g00k42TvCXgO5uO13PkctpCdggWCGo2ok 4UwPQWSu/uGNzaH+9CjxV8wMT4Sv8R81U9yYiCq0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pengfei Xu , Jan Kara , stable@kernel.org, Theodore Tso Subject: [PATCH 5.15 161/290] ext4: avoid unaccounted block allocation when expanding inode Date: Tue, 10 Jan 2023 19:04:13 +0100 Message-Id: <20230110180037.448444501@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110180031.620810905@linuxfoundation.org> References: <20230110180031.620810905@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jan Kara commit 8994d11395f8165b3deca1971946f549f0822630 upstream. When expanding inode space in ext4_expand_extra_isize_ea() we may need to allocate external xattr block. If quota is not initialized for the inode, the block allocation will not be accounted into quota usage. Make sure the quota is initialized before we try to expand inode space. Reported-by: Pengfei Xu Link: https://lore.kernel.org/all/Y5BT+k6xWqthZc1P@xpf.sh.intel.com Signed-off-by: Jan Kara Cc: stable@kernel.org Link: https://lore.kernel.org/r/20221207115937.26601-2-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5813,6 +5813,14 @@ static int __ext4_expand_extra_isize(str return 0; } + /* + * We may need to allocate external xattr block so we need quotas + * initialized. Here we can be called with various locks held so we + * cannot affort to initialize quotas ourselves. So just bail. + */ + if (dquot_initialize_needed(inode)) + return -EAGAIN; + /* try to expand with EAs present */ error = ext4_expand_extra_isize_ea(inode, new_extra_isize, raw_inode, handle);