From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A183C4332F for ; Wed, 4 Jan 2023 16:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239992AbjADQ1S (ORCPT ); Wed, 4 Jan 2023 11:27:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239805AbjADQ1O (ORCPT ); Wed, 4 Jan 2023 11:27:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A6F83F12C for ; Wed, 4 Jan 2023 08:27:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F3BA661798 for ; Wed, 4 Jan 2023 16:27:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E25F7C433EF; Wed, 4 Jan 2023 16:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672849629; bh=OnJvRWIhGVd7pD6LqKsGVV/TXdTXCYRga5yDMdMpcME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yG3b4ektkqHlpJcJy+57/aMV2LTvC8lXjjrxatuR2XRLoYJXIbpw8d/842BYrYEvf QgMVK+gusK1VG/O0J04BdrF8NGbw1iyIEoi0t2C0qQoZns6GzNrDPa38Rb/BfPZWl8 rJbcqvPgYAtm6cYsc/mdEUyzjErDlVx07GGly1s4= 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 6.0 166/177] ext4: avoid unaccounted block allocation when expanding inode Date: Wed, 4 Jan 2023 17:07:37 +0100 Message-Id: <20230104160512.709302844@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230104160507.635888536@linuxfoundation.org> References: <20230104160507.635888536@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 @@ -5838,6 +5838,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);