This is a note to let you know that I've just added the patch titled ext4: avoid unaccounted block allocation when expanding inode to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ext4-avoid-unaccounted-block-allocation-when-expanding-inode.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 8994d11395f8165b3deca1971946f549f0822630 Mon Sep 17 00:00:00 2001 From: Jan Kara <jack@xxxxxxx> Date: Wed, 7 Dec 2022 12:59:28 +0100 Subject: ext4: avoid unaccounted block allocation when expanding inode From: Jan Kara <jack@xxxxxxx> 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 <pengfei.xu@xxxxxxxxx> Link: https://lore.kernel.org/all/Y5BT+k6xWqthZc1P@xxxxxxxxxxxxxxxx Signed-off-by: Jan Kara <jack@xxxxxxx> Cc: stable@xxxxxxxxxx Link: https://lore.kernel.org/r/20221207115937.26601-2-jack@xxxxxxx Signed-off-by: Theodore Ts'o <tytso@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- 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); Patches currently in stable-queue which might be from jack@xxxxxxx are queue-6.0/ext4-fix-deadlock-due-to-mbcache-entry-corruption.patch queue-6.0/ext4-fix-use-after-free-in-ext4_orphan_cleanup.patch queue-6.0/ext4-avoid-unaccounted-block-allocation-when-expanding-inode.patch queue-6.0/ext4-check-and-assert-if-marking-an-no_delete-evicting-inode-dirty.patch queue-6.0/ext4-fix-bug_on-in-__es_tree_search-caused-by-bad-boot-loader-inode.patch queue-6.0/ext4-fix-inode-leak-in-ext4_xattr_inode_create-on-an-error-path.patch queue-6.0/ext4-add-helper-to-check-quota-inums.patch queue-6.0/ext4-fix-corruption-when-online-resizing-a-1k-bigalloc-fs.patch queue-6.0/ext4-allocate-extended-attribute-value-in-vmalloc-area.patch queue-6.0/ext4-fix-uninititialized-value-in-ext4_evict_inode.patch queue-6.0/ext4-fix-corrupt-backup-group-descriptors-after-online-resize.patch queue-6.0/ext4-init-quota-for-old.inode-in-ext4_rename.patch queue-6.0/ext4-add-ext4_iget_bad-flag-to-prevent-unexpected-bad-inode.patch queue-6.0/ext4-avoid-bug_on-when-creating-xattrs.patch queue-6.0/ext4-fix-bug_on-in-__es_tree_search-caused-by-bad-quota-inode.patch queue-6.0/ext4-fix-bad-checksum-after-online-resize.patch queue-6.0/ext4-silence-the-warning-when-evicting-inode-with-dioread_nolock.patch queue-6.0/ext2-unbugger-ext2_empty_dir.patch queue-6.0/ext4-initialize-quota-before-expanding-inode-in-setproject-ioctl.patch